diff --git a/tests/Bw.VaultDigest.UnitTests/Bw.VaultDigest.UnitTests.csproj b/tests/Bw.VaultDigest.UnitTests/Bw.VaultDigest.UnitTests.csproj index fe72d63..b36dd30 100644 --- a/tests/Bw.VaultDigest.UnitTests/Bw.VaultDigest.UnitTests.csproj +++ b/tests/Bw.VaultDigest.UnitTests/Bw.VaultDigest.UnitTests.csproj @@ -12,9 +12,9 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/Bw.VaultDigest.UnitTests/GlobalUsings.cs b/tests/Bw.VaultDigest.UnitTests/GlobalUsings.cs index 74fdc36..32f0767 100644 --- a/tests/Bw.VaultDigest.UnitTests/GlobalUsings.cs +++ b/tests/Bw.VaultDigest.UnitTests/GlobalUsings.cs @@ -1,4 +1,4 @@ global using Xunit; -global using FluentAssertions; +global using Shouldly; global using Moq; global using AutoFixture; \ No newline at end of file diff --git a/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/GetLoginsTests.cs b/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/GetLoginsTests.cs index 1d9f470..c920a28 100644 --- a/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/GetLoginsTests.cs +++ b/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/GetLoginsTests.cs @@ -149,7 +149,7 @@ public async Task GetLogins_WhenUnauthorized(string password, string sessionToke VerifyLoginCalled(keys.ClientId, keys.ClientSecret, Times.Once()); VerifyUnlockCalled(password, Times.Once()); VerifyGetLoginsCalled(sessionToken, Times.Once()); - logins.Should().BeEquivalentTo(items); + logins.ShouldBeEquivalentTo(items); } [Theory] @@ -171,7 +171,7 @@ public async Task GetLogins_WhenLocked(string password, string sessionToken, Lis VerifyLoginNotCalled(); VerifyUnlockCalled(password, Times.Once()); VerifyGetLoginsCalled(sessionToken, Times.Once()); - logins.Should().BeEquivalentTo(items); + logins.ShouldBeEquivalentTo(items); } [Theory] @@ -192,9 +192,7 @@ public async Task GetLogins_WhenResultFailed(string password, string sessionToke Func act = () => _bwClientMock.Object.GetItems(); await act - .Should() - .ThrowAsync() - .WithMessage("Failed to get logins"); + .ShouldThrowAsync("Failed to get logins"); VerifyLoginNotCalled(); VerifyUnlockCalled(password, Times.Once()); @@ -215,9 +213,7 @@ public async Task GetLogins_WhenFailedToGetPassword() Func act = () => _bwClientMock.Object.GetItems(); await act - .Should() - .ThrowAsync() - .WithMessage("Could not retrieve master password"); + .ShouldThrowAsync("Could not retrieve master password"); VerifyLoginNotCalled(); VerifyUnlockCalled(It.IsAny(), Times.Never()); @@ -236,9 +232,7 @@ public async Task GetLogins_WhenFailedToGetApiKey() Func act = () => _bwClientMock.Object.GetItems(); await act - .Should() - .ThrowAsync() - .WithMessage("Could not retrieve Api Keys to login"); + .ShouldThrowAsync("Could not retrieve Api Keys to login"); VerifyLoginNotCalled(); VerifyUnlockCalled(It.IsAny(), Times.Never()); @@ -257,9 +251,7 @@ public async Task GetLogins_WhenUnknownStatusReceived() Func act = () => _bwClientMock.Object.GetItems(); await act - .Should() - .ThrowAsync() - .WithMessage("Unknown status received"); + .ShouldThrowAsync("Unknown status received"); VerifyLoginNotCalled(); VerifyUnlockCalled(It.IsAny(), Times.Never()); @@ -291,6 +283,6 @@ public async Task GetLogins_ShouldSyncWhenOutdated(string password, string sessi .Verify(c => c.Request(EmptyEnvVars, "sync"), Times.Once()); VerifyUnlockCalled(password, Times.Once()); VerifyGetLoginsCalled(sessionToken, Times.Once()); - logins.Should().BeEquivalentTo(items); + logins.ShouldBeEquivalentTo(items); } } \ No newline at end of file diff --git a/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/SerializationTests.cs b/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/SerializationTests.cs index b347914..17e3c63 100644 --- a/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/SerializationTests.cs +++ b/tests/Bw.VaultDigest.UnitTests/Infrastructure/BwClientTests/SerializationTests.cs @@ -194,6 +194,6 @@ public void Deserialize_ValidJson_ReturnsObject() ] """; var obj = JsonSerializer.Deserialize>(str, BwClient.SerializeOptions); - obj.Should().NotBeNull(); + obj.ShouldNotBeNull(); } } \ No newline at end of file diff --git a/tests/Bw.VaultDigest.UnitTests/Infrastructure/LoginsMappingTests.cs b/tests/Bw.VaultDigest.UnitTests/Infrastructure/LoginsMappingTests.cs index 3ec6908..701a61d 100644 --- a/tests/Bw.VaultDigest.UnitTests/Infrastructure/LoginsMappingTests.cs +++ b/tests/Bw.VaultDigest.UnitTests/Infrastructure/LoginsMappingTests.cs @@ -113,8 +113,9 @@ public void LoginMapping_ShouldMapLoginsOnly() var logins = items.ToLogins(DateTime.Now); - logins.Should().HaveCount(loginItems.Length); - logins.Should().OnlyContain(l => loginItems.Any(li => li.Id == l.Id)); + logins.Count.ShouldBe(loginItems.Length); + logins.ShouldContain(l => loginItems.Any(li => li.Id == l.Id)); + logins.ShouldNotContain(l => loginItems.All(li => li.Id != l.Id)); } private class StrengthCalculationData : TheoryData @@ -215,10 +216,10 @@ public void LoginMapping_StrengthCalculation(Strength expectedStrength, string p var logins = items.ToLogins(_fixture.Create()); - logins.Should().HaveCount(1); - logins[0].Id.Should().Be(item.Id); - logins[0].Name.Should().Be(item.Name); - logins[0].Strength.Should().Be(expectedStrength); + logins.Count.ShouldBe(1); + logins[0].Id.ShouldBe(item.Id); + logins[0].Name.ShouldBe(item.Name); + logins[0].Strength.ShouldBe(expectedStrength); } private class AgeCalculationData : TheoryData @@ -256,9 +257,9 @@ public void LoginMapping_AgeCalculation(Age expectedAge, DateTime date, DateTime var logins = items.ToLogins(now); - logins.Should().HaveCount(1); - logins[0].Id.Should().Be(item.Id); - logins[0].Name.Should().Be(item.Name); - logins[0].Age.Should().Be(expectedAge); + logins.Count.ShouldBe(1); + logins[0].Id.ShouldBe(item.Id); + logins[0].Name.ShouldBe(item.Name); + logins[0].Age.ShouldBe(expectedAge); } } \ No newline at end of file diff --git a/tests/Bw.VaultDigest.UnitTests/Services/DigestServiceTests.cs b/tests/Bw.VaultDigest.UnitTests/Services/DigestServiceTests.cs index 70e84ae..3a1624d 100644 --- a/tests/Bw.VaultDigest.UnitTests/Services/DigestServiceTests.cs +++ b/tests/Bw.VaultDigest.UnitTests/Services/DigestServiceTests.cs @@ -30,12 +30,12 @@ public void ToStrengthSlices_Spec() var result = logins.ToList().ToStrengthSlices(); - result.Should().HaveCount(5); - result.Should().Contain(s => s.FillColor == Colors.Red && s.Value == 5); - result.Should().Contain(s => s.FillColor == Colors.Orange && s.Value == 7); - result.Should().Contain(s => s.FillColor == Colors.Yellow && s.Value == 9); - result.Should().Contain(s => s.FillColor == Colors.LightGreen && s.Value == 12); - result.Should().Contain(s => s.FillColor == Colors.Green && s.Value == 15); + result.Count.ShouldBe(5); + result.ShouldContain(s => s.FillColor == Colors.Red && s.Value == 5); + result.ShouldContain(s => s.FillColor == Colors.Orange && s.Value == 7); + result.ShouldContain(s => s.FillColor == Colors.Yellow && s.Value == 9); + result.ShouldContain(s => s.FillColor == Colors.LightGreen && s.Value == 12); + result.ShouldContain(s => s.FillColor == Colors.Green && s.Value == 15); } [Fact] @@ -51,11 +51,11 @@ public void ToAgesSlices_Spec() var result = logins.ToList().ToAgeSlices(); - result.Should().HaveCount(5); - result.Should().Contain(s => s.FillColor == Colors.Red && s.Value == 5); - result.Should().Contain(s => s.FillColor == Colors.Orange && s.Value == 7); - result.Should().Contain(s => s.FillColor == Colors.Yellow && s.Value == 9); - result.Should().Contain(s => s.FillColor == Colors.LightGreen && s.Value == 12); - result.Should().Contain(s => s.FillColor == Colors.Green && s.Value == 15); + result.Count.ShouldBe(5); + result.ShouldContain(s => s.FillColor == Colors.Red && s.Value == 5); + result.ShouldContain(s => s.FillColor == Colors.Orange && s.Value == 7); + result.ShouldContain(s => s.FillColor == Colors.Yellow && s.Value == 9); + result.ShouldContain(s => s.FillColor == Colors.LightGreen && s.Value == 12); + result.ShouldContain(s => s.FillColor == Colors.Green && s.Value == 15); } } \ No newline at end of file