-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ResourceResolver>(); | ||
ServiceProvider = svcCollection.BuildServiceProvider(); | ||
} | ||
|
||
public ServiceProvider ServiceProvider { get; private set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ContainerFixture> | ||
{ | ||
public ResourceResolverTest(ContainerFixture fixture) | ||
{ | ||
serviceProvider = fixture.ServiceProvider; | ||
resourceResolver = serviceProvider.GetService<ResourceResolver>() ?? | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<Platforms>x64;ARM64</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\TableCloth\TableCloth.csproj" /> | ||
</ItemGroup> | ||
|
||
<Import Project="..\TableCloth.Shared\TableCloth.Shared.projitems" Label="Shared" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters