diff --git a/src/TableCloth.Test/ContainerFixture.cs b/src/TableCloth.Test/ContainerFixture.cs new file mode 100644 index 00000000..fb73a90a --- /dev/null +++ b/src/TableCloth.Test/ContainerFixture.cs @@ -0,0 +1,24 @@ +namespace TableCloth.Test; + +using Microsoft.Extensions.DependencyInjection; +using TableCloth.Components; +using TableCloth.Resources; + +public class ContainerFixture +{ + public ContainerFixture() + { + var svcCollection = new ServiceCollection(); + svcCollection + .AddLogging() + .AddHttpClient(nameof(TableCloth), c => + { + c.DefaultRequestHeaders.Add("User-Agent", StringResources.UserAgentText); + }); + + svcCollection.AddSingleton(); + ServiceProvider = svcCollection.BuildServiceProvider(); + } + + public ServiceProvider ServiceProvider { get; private set; } +} diff --git a/src/TableCloth.Test/ResourceResolverTest.cs b/src/TableCloth.Test/ResourceResolverTest.cs new file mode 100644 index 00000000..5c9f3bb9 --- /dev/null +++ b/src/TableCloth.Test/ResourceResolverTest.cs @@ -0,0 +1,38 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TableCloth.Components; + +namespace TableCloth.Test +{ + public class ResourceResolverTest : IClassFixture + { + public ResourceResolverTest(ContainerFixture fixture) + { + serviceProvider = fixture.ServiceProvider; + resourceResolver = serviceProvider.GetService() ?? + throw new Exception("Cannot obtain resource resolver due to configuration"); + } + + private IServiceProvider serviceProvider; + private ResourceResolver resourceResolver; + + [Fact] + public async Task TestGetLatestVersion() + { + // Arrange + const string repoOwner = "yourtablecloth"; + const string repoName = "TableCloth"; + + // Act + var result = await resourceResolver.GetLatestVersion(repoOwner, repoName); + + // Assert + Assert.NotNull(result); + Assert.NotEmpty(result); + } + } +} diff --git a/src/TableCloth.Test/TableCloth.Test.csproj b/src/TableCloth.Test/TableCloth.Test.csproj new file mode 100644 index 00000000..b039d6b3 --- /dev/null +++ b/src/TableCloth.Test/TableCloth.Test.csproj @@ -0,0 +1,32 @@ + + + + net6.0-windows10.0.18362.0 + enable + enable + + false + + x64;ARM64 + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + diff --git a/src/TableCloth.Test/Usings.cs b/src/TableCloth.Test/Usings.cs new file mode 100644 index 00000000..8c927eb7 --- /dev/null +++ b/src/TableCloth.Test/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/src/TableCloth.sln b/src/TableCloth.sln index 341811e1..e800f9dd 100644 --- a/src/TableCloth.sln +++ b/src/TableCloth.sln @@ -32,6 +32,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableCloth.ResourceBuilder" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Loom", "Loom\Loom.csproj", "{25CA9322-D817-4F66-AC5A-8A88794162AF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableCloth.Test", "TableCloth.Test\TableCloth.Test.csproj", "{00E9E604-57A3-41DF-AF08-F0436D4FF9BA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -92,6 +94,14 @@ Global {25CA9322-D817-4F66-AC5A-8A88794162AF}.Release|ARM64.Build.0 = Release|ARM64 {25CA9322-D817-4F66-AC5A-8A88794162AF}.Release|x64.ActiveCfg = Release|x64 {25CA9322-D817-4F66-AC5A-8A88794162AF}.Release|x64.Build.0 = Release|x64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Debug|ARM64.Build.0 = Debug|ARM64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Debug|x64.ActiveCfg = Debug|x64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Debug|x64.Build.0 = Debug|x64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Release|ARM64.ActiveCfg = Release|ARM64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Release|ARM64.Build.0 = Release|ARM64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Release|x64.ActiveCfg = Release|x64 + {00E9E604-57A3-41DF-AF08-F0436D4FF9BA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -100,6 +110,7 @@ Global SolutionGuid = {7EAF7AB7-15CC-4504-8D15-C631B0996E8F} EndGlobalSection GlobalSection(SharedMSBuildProjectFiles) = preSolution + TableCloth.Shared\TableCloth.Shared.projitems*{00e9e604-57a3-41df-af08-f0436d4ff9ba}*SharedItemsImports = 5 TableCloth.Shared\TableCloth.Shared.projitems*{0f58b6a7-cca8-471a-b767-01c7b8f6e839}*SharedItemsImports = 13 TableCloth.Shared\TableCloth.Shared.projitems*{25ca9322-d817-4f66-ac5a-8a88794162af}*SharedItemsImports = 5 TableCloth.Shared\TableCloth.Shared.projitems*{2d6cd03c-52b2-46f2-8ec1-7480e7a92e5e}*SharedItemsImports = 5