Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
apfohl committed Jan 31, 2024
1 parent ebdfaf3 commit bc81d15
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
13 changes: 9 additions & 4 deletions HotwiredBooks.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
<Assembly Path="/home/andreas/.nuget/packages/erroror/1.3.0/lib/net6.0/ErrorOr.dll" />
&lt;/AssemblyExplorer&gt;</s:String>

<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=56f95705_002D69f0_002D4d78_002D9fec_002Db8596a7edfd4/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="Create_inserts_value_into_repository" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Project Location="/Users/andreas/Developer/HotwiredBooks/HotwiredBooksTests" Presentation="&amp;lt;HotwiredBooksTests&amp;gt;" /&gt;
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=56f95705_002D69f0_002D4d78_002D9fec_002Db8596a7edfd4/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="Create_inserts_value_into_repository" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;TestAncestor&gt;
&lt;TestId&gt;NUnit3x::8CACA52D-A3E1-4F72-94DD-F267B74B9259::net8.0::HotwiredBooksTests.HtmlHelperExtensionsTests.DomId_creates_correct_id&lt;/TestId&gt;
&lt;/TestAncestor&gt;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=7a5365d0_002Db616_002D4d4b_002D83e3_002Df6bda9b641db/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="Create_inserts_value_into_repository #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Project Location="/Users/andreas/Developer/HotwiredBooks/HotwiredBooksTests" Presentation="&amp;lt;HotwiredBooksTests&amp;gt;" /&gt;
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=7a5365d0_002Db616_002D4d4b_002D83e3_002Df6bda9b641db/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="Create_inserts_value_into_repository #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;TestAncestor&gt;
&lt;TestId&gt;NUnit3x::8CACA52D-A3E1-4F72-94DD-F267B74B9259::net8.0::HotwiredBooksTests.HtmlHelperExtensionsTests&lt;/TestId&gt;
&lt;TestId&gt;NUnit3x::8CACA52D-A3E1-4F72-94DD-F267B74B9259::net8.0::HotwiredBooksTests.MemoryBasedBookRepositoryTests&lt;/TestId&gt;
&lt;/TestAncestor&gt;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>
3 changes: 2 additions & 1 deletion HotwiredBooksTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global using NUnit.Framework;
global using NUnit.Framework;
global using FluentAssertions;
1 change: 1 addition & 0 deletions HotwiredBooksTests/HotwiredBooksTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
Expand Down
4 changes: 2 additions & 2 deletions HotwiredBooksTests/HtmlHelperExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void DomId_creates_correct_id(object objectOrType, string prefix,
{
var id = HtmlHelperExtensions.DomId(null, objectOrType, prefix);

Assert.That(id, Is.EqualTo(expectedId));
id.Should().Be(expectedId);
}

private static IEnumerable<object[]> DomClassTestCases
Expand All @@ -50,6 +50,6 @@ public static void DomClass_creates_correct_class(object objectOrType, string pr
{
var @class = HtmlHelperExtensions.DomClass(null, objectOrType, prefix);

Assert.That(@class, Is.EqualTo(expectedClass));
@class.Should().Be(expectedClass);
}
}
13 changes: 7 additions & 6 deletions HotwiredBooksTests/MemoryBasedBookRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ public static class MemoryBasedBookRepositoryTests
public static async Task Create_inserts_value_into_repository()
{
var repository = new MemoryBasedBooksRepository();

const string title = "ABC";
const string author = "DEF";

var book = await repository.Create(title, author);
book.Switch(b => Assert.Multiple(() =>
book.Switch(b =>
{
Assert.That(b.Title, Is.EqualTo(title));
Assert.That(b.Author, Is.EqualTo(author));
Assert.That(b.Id, Is.Not.EqualTo(new Guid()));
}),
b.Title.Should().Be(title);
b.Author.Should().Be(author);
b.Id.Should().NotBe(Guid.Empty);
},
_ => Assert.Fail()
);

Expand All @@ -28,6 +29,6 @@ from created in Task.FromResult(book)
from read in repository.Lookup(created.Id)
select created == read;

(await areEqual).Switch(_ => Assert.Pass(), _ => Assert.Fail());
(await areEqual).Switch(eq => eq.Should().BeTrue(), _ => Assert.Fail());
}
}

0 comments on commit bc81d15

Please sign in to comment.