From e5ed8cab908f981c9a837eb2d5e268934534aad9 Mon Sep 17 00:00:00 2001 From: Werner Mairl Date: Sun, 1 Jul 2018 10:10:50 +0200 Subject: [PATCH] start test (xUnit) Infrastructure - added first test project to the solution - following some pattern identified in https://github.com/dotnet or BaGet - multiple test-csproj inside a folder "test(s)" - BaGet uses CamelCase for FolderName => "Tests" not "tests" - plural for tests ? - in github/dotnet the "test" folde sometimes is brother of "src", sometimes is child of "src" => child of src selected! -one xUnit -csproj per implementation-csproj -use suffix ".Tests" for file, folder and default-namespace implementation => tests ----------------------------------------- src/BaGet.Core.csproj => src/Tests/Baget.Core.Tests.csproj --- BaGet.sln | 6 ++++++ .../BaGet.Core.Tests/BaGet.Core.Tests.csproj | 20 +++++++++++++++++++ .../FilePackageStorageServiceTests.cs | 18 +++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 src/Tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj create mode 100644 src/Tests/BaGet.Core.Tests/FilePackageStorageServiceTests.cs diff --git a/BaGet.sln b/BaGet.sln index aec0edec8..89fd65bb0 100644 --- a/BaGet.sln +++ b/BaGet.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaGet.Tools.ImportDownloads EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaGet.Tools.AzureSearchImporter", "src\BaGet.Tools.AzureSearchImporter\BaGet.Tools.AzureSearchImporter.csproj", "{B232DAFE-5CE8-441F-ACC7-2BB54BCD094F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BaGet.Core.Tests", "src\Tests\BaGet.Core.Tests\BaGet.Core.Tests.csproj", "{89AB1AE2-6CAA-4809-8B74-D78CBE00B049}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {B232DAFE-5CE8-441F-ACC7-2BB54BCD094F}.Debug|Any CPU.Build.0 = Debug|Any CPU {B232DAFE-5CE8-441F-ACC7-2BB54BCD094F}.Release|Any CPU.ActiveCfg = Release|Any CPU {B232DAFE-5CE8-441F-ACC7-2BB54BCD094F}.Release|Any CPU.Build.0 = Release|Any CPU + {89AB1AE2-6CAA-4809-8B74-D78CBE00B049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89AB1AE2-6CAA-4809-8B74-D78CBE00B049}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89AB1AE2-6CAA-4809-8B74-D78CBE00B049}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89AB1AE2-6CAA-4809-8B74-D78CBE00B049}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj b/src/Tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj new file mode 100644 index 000000000..d8c9875b9 --- /dev/null +++ b/src/Tests/BaGet.Core.Tests/BaGet.Core.Tests.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + + + + + + diff --git a/src/Tests/BaGet.Core.Tests/FilePackageStorageServiceTests.cs b/src/Tests/BaGet.Core.Tests/FilePackageStorageServiceTests.cs new file mode 100644 index 000000000..25023a0ea --- /dev/null +++ b/src/Tests/BaGet.Core.Tests/FilePackageStorageServiceTests.cs @@ -0,0 +1,18 @@ +using System; +using Xunit; +using BaGet.Core.Services; +using System.IO; + +namespace BaGet.Core.Tests +{ + public class FilePackageStorageServiceTests + { + [Fact] + public void Create_On_Not_Existing_Folder() + { + string validButNotExistingPath = Path.Combine(Path.GetTempPath(), System.Guid.NewGuid().ToString("N")); + Assert.False(Directory.Exists(validButNotExistingPath)); + IPackageStorageService service = new FilePackageStorageService(validButNotExistingPath); + } + } +}