Skip to content

Commit

Permalink
Implement XUnit (#14)
Browse files Browse the repository at this point in the history
* correct webfinger namespace

* create unit test project, add poc unit test

* move solution up one folder above src and test

* remove working-directory from gh actions

solution moved up a directory and we want to build/test all.
  • Loading branch information
edmistond authored Nov 22, 2022
1 parent e42eab8 commit 8ffc93c
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 30 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
pull_request:
branches: [ "main" ]

defaults:
run:
working-directory: src

jobs:
api-build:
name: WebApp Build
Expand Down
39 changes: 39 additions & 0 deletions Smilodon.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33103.184
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp", "src\WebApp\WebApp.csproj", "{EF2B2EA7-D380-46EA-A2CE-D7C9D22B18FA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{74FC9674-053B-480C-84AC-F6AAF8B82239}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9EC4E573-048F-40B7-8721-E28857532DF0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApp.Test", "test\WebApp.Test\WebApp.Test.csproj", "{972B3171-DDE1-4CF8-863E-B45875440A80}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EF2B2EA7-D380-46EA-A2CE-D7C9D22B18FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF2B2EA7-D380-46EA-A2CE-D7C9D22B18FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF2B2EA7-D380-46EA-A2CE-D7C9D22B18FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF2B2EA7-D380-46EA-A2CE-D7C9D22B18FA}.Release|Any CPU.Build.0 = Release|Any CPU
{972B3171-DDE1-4CF8-863E-B45875440A80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{972B3171-DDE1-4CF8-863E-B45875440A80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{972B3171-DDE1-4CF8-863E-B45875440A80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{972B3171-DDE1-4CF8-863E-B45875440A80}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EF2B2EA7-D380-46EA-A2CE-D7C9D22B18FA} = {74FC9674-053B-480C-84AC-F6AAF8B82239}
{972B3171-DDE1-4CF8-863E-B45875440A80} = {9EC4E573-048F-40B7-8721-E28857532DF0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B464DC23-8514-4B57-BA12-524A7C3994FA}
EndGlobalSection
EndGlobal
25 changes: 0 additions & 25 deletions src/Smilodon.sln

This file was deleted.

2 changes: 1 addition & 1 deletion src/WebApp/Api/Webfinger/WebfingerEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;

namespace Smilodon.WebApp.Api.Admin;
namespace Smilodon.WebApp.Api.Webfinger;

public static class WebfingerEndpoints
{
Expand Down
1 change: 1 addition & 0 deletions src/WebApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Smilodon.WebApp.Api.Admin;
using Smilodon.WebApp.Api.Webfinger;

var builder = WebApplication.CreateBuilder(args);

Expand Down
17 changes: 17 additions & 0 deletions test/WebApp.Test/Api/Webfinger/WebfingerEndpointsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using AutoFixture.Xunit2;
using Microsoft.AspNetCore.Http.HttpResults;
using Smilodon.WebApp.Api.Webfinger;

namespace WebApp.Test.Api.Webfinger
{
public class WebfingerEndpointsTests
{
[Theory, AutoData]
public async Task GetAllAccountReturnsResource(string resourceName)
{
var result = await WebfingerEndpoints.GetAllAccount(resourceName);
result.Should().BeOfType<Ok<string>>()
.Which.Value.Should().Be(resourceName);
}
}
}
3 changes: 3 additions & 0 deletions test/WebApp.Test/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global using Xunit;
global using FluentAssertions;
global using AutoFixture;
35 changes: 35 additions & 0 deletions test/WebApp.Test/WebApp.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.17.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\WebApp\WebApp.csproj" />
</ItemGroup>

</Project>

0 comments on commit 8ffc93c

Please sign in to comment.