diff --git a/Source/EventFlow.EntityFramework.Tests/MsSql/EfMsSqlReadStoreIncludeTests.cs b/Source/EventFlow.EntityFramework.Tests/MsSql/EfMsSqlReadStoreIncludeTests.cs index a73f2d312..9f7062eeb 100644 --- a/Source/EventFlow.EntityFramework.Tests/MsSql/EfMsSqlReadStoreIncludeTests.cs +++ b/Source/EventFlow.EntityFramework.Tests/MsSql/EfMsSqlReadStoreIncludeTests.cs @@ -31,9 +31,9 @@ using EventFlow.Extensions; using EventFlow.TestHelpers; using EventFlow.TestHelpers.MsSql; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.EntityFramework.Tests.MsSql { @@ -80,9 +80,9 @@ await CommandBus .ConfigureAwait(false); // Assert - readModel.Should().NotBeNull(); - readModel.Name.Should().Be("Bob"); - readModel.Addresses.Should().BeNullOrEmpty(); + readModel.ShouldNotBeNull(); + readModel.Name.ShouldBe("Bob"); + readModel.Addresses.ShouldBeEmpty(); } [Test] @@ -114,11 +114,21 @@ await CommandBus .ConfigureAwait(false); // Assert - readModel.Should().NotBeNull(); - readModel.NumberOfAddresses.Should().Be(2); - readModel.Addresses.Should().HaveCount(2); - readModel.Addresses.Should().ContainEquivalentOf(address1); - readModel.Addresses.Should().ContainEquivalentOf(address2); + readModel.ShouldNotBeNull(); + readModel.NumberOfAddresses.ShouldBe(2); + readModel.Addresses.Count.ShouldBe(2); + + readModel.Addresses.ShouldContain(a => + a.Street == address1.Street && + a.PostalCode == address1.PostalCode && + a.City == address1.City && + a.Country == address1.Country); + + readModel.Addresses.ShouldContain(a => + a.Street == address2.Street && + a.PostalCode == address2.PostalCode && + a.City == address2.City && + a.Country == address2.Country); } } } \ No newline at end of file diff --git a/Source/EventFlow.Examples.Shipping.Tests/DateTimeExtensions.cs b/Source/EventFlow.Examples.Shipping.Tests/DateTimeExtensions.cs new file mode 100644 index 000000000..d15d8fdf9 --- /dev/null +++ b/Source/EventFlow.Examples.Shipping.Tests/DateTimeExtensions.cs @@ -0,0 +1,12 @@ +using System; + +namespace EventFlow.Examples.Shipping.Tests; + +public static class DateTimeExtensions +{ + public static DateTime October(this int day, int year) => new(year, 10, day); + public static DateTime November(this int day, int year) => new(year, 11, day); + public static DateTime January(this int day, int year) => new(year, 1, day); + + public static DateTime At(this DateTime date, int hours, int minutes) => new(date.Year, date.Month, date.Day, hours, minutes, 0); +} \ No newline at end of file diff --git a/Source/EventFlow.Examples.Shipping.Tests/IntegrationTests/Scenarios.cs b/Source/EventFlow.Examples.Shipping.Tests/IntegrationTests/Scenarios.cs index a0c6eaef5..b363c18f1 100644 --- a/Source/EventFlow.Examples.Shipping.Tests/IntegrationTests/Scenarios.cs +++ b/Source/EventFlow.Examples.Shipping.Tests/IntegrationTests/Scenarios.cs @@ -33,7 +33,6 @@ using EventFlow.Examples.Shipping.Domain.Model.VoyageModel.Commands; using EventFlow.Examples.Shipping.Queries.InMemory; using EventFlow.TestHelpers; -using FluentAssertions.Extensions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; diff --git a/Source/EventFlow.Examples.Shipping.Tests/UnitTests/Domain/Model/CargoModel/Speficications/TransportLegsAreConnectedSpecificationTests.cs b/Source/EventFlow.Examples.Shipping.Tests/UnitTests/Domain/Model/CargoModel/Speficications/TransportLegsAreConnectedSpecificationTests.cs index 28e1b4fcf..b6f6d3b06 100644 --- a/Source/EventFlow.Examples.Shipping.Tests/UnitTests/Domain/Model/CargoModel/Speficications/TransportLegsAreConnectedSpecificationTests.cs +++ b/Source/EventFlow.Examples.Shipping.Tests/UnitTests/Domain/Model/CargoModel/Speficications/TransportLegsAreConnectedSpecificationTests.cs @@ -20,14 +20,14 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +using System.Linq; using EventFlow.Examples.Shipping.Domain.Model.CargoModel.Entities; using EventFlow.Examples.Shipping.Domain.Model.CargoModel.Specifications; using EventFlow.Examples.Shipping.Domain.Model.VoyageModel; using EventFlow.Examples.Shipping.Domain.Model.VoyageModel.Entities; using EventFlow.TestHelpers; -using FluentAssertions; -using FluentAssertions.Extensions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Examples.Shipping.Tests.UnitTests.Domain.Model.CargoModel.Speficications { @@ -50,8 +50,8 @@ public void Valid() var why = sut.WhyIsNotSatisfiedBy(transportLegs); // Assert - isSatisfiedBy.Should().BeTrue(); - why.Should().HaveCount(0); + isSatisfiedBy.ShouldBeTrue(); + why.Count().ShouldBe(0); } [Test] @@ -70,8 +70,8 @@ public void UnloadIsAfterLoad() var why = sut.WhyIsNotSatisfiedBy(transportLegs); // Assert - isSatisfiedBy.Should().BeFalse(); - why.Should().HaveCount(1); + isSatisfiedBy.ShouldBeFalse(); + why.Count().ShouldBe(1); } [Test] @@ -90,8 +90,8 @@ public void UnloadAndLoadLocationsAreDifferent() var why = sut.WhyIsNotSatisfiedBy(transportLegs); // Assert - isSatisfiedBy.Should().BeFalse(); - why.Should().HaveCount(1); + isSatisfiedBy.ShouldBeFalse(); + why.Count().ShouldBe(1); } } } \ No newline at end of file diff --git a/Source/EventFlow.Examples.Shipping.Tests/UnitTests/ExternalServices/Routing/RoutingServiceTests.cs b/Source/EventFlow.Examples.Shipping.Tests/UnitTests/ExternalServices/Routing/RoutingServiceTests.cs index df879ec46..1abf4ca8c 100644 --- a/Source/EventFlow.Examples.Shipping.Tests/UnitTests/ExternalServices/Routing/RoutingServiceTests.cs +++ b/Source/EventFlow.Examples.Shipping.Tests/UnitTests/ExternalServices/Routing/RoutingServiceTests.cs @@ -24,9 +24,8 @@ using EventFlow.Examples.Shipping.Domain.Model.VoyageModel; using EventFlow.Examples.Shipping.ExternalServices.Routing; using EventFlow.TestHelpers; -using FluentAssertions; -using FluentAssertions.Extensions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Examples.Shipping.Tests.UnitTests.ExternalServices.Routing { @@ -51,7 +50,7 @@ public void Itinerary() // Assert // TODO: Assert list of legs - itineraries.Should().HaveCount(1); + itineraries.Count.ShouldBe(1); } } } \ No newline at end of file diff --git a/Source/EventFlow.Examples.Shipping.Tests/Voyages.cs b/Source/EventFlow.Examples.Shipping.Tests/Voyages.cs index 8055bed0e..10b04e802 100644 --- a/Source/EventFlow.Examples.Shipping.Tests/Voyages.cs +++ b/Source/EventFlow.Examples.Shipping.Tests/Voyages.cs @@ -23,7 +23,6 @@ using System.Collections.Generic; using EventFlow.Examples.Shipping.Domain.Model.VoyageModel; using EventFlow.Examples.Shipping.Domain.Model.VoyageModel.ValueObjects; -using FluentAssertions.Extensions; namespace EventFlow.Examples.Shipping.Tests { diff --git a/Source/EventFlow.Hangfire.Tests/Integration/HangfireJobSchedulerTests.cs b/Source/EventFlow.Hangfire.Tests/Integration/HangfireJobSchedulerTests.cs index 277db2180..3f3a1ee45 100644 --- a/Source/EventFlow.Hangfire.Tests/Integration/HangfireJobSchedulerTests.cs +++ b/Source/EventFlow.Hangfire.Tests/Integration/HangfireJobSchedulerTests.cs @@ -36,13 +36,12 @@ using EventFlow.TestHelpers.Aggregates.Commands; using EventFlow.TestHelpers.Aggregates.Events; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; -using FluentAssertions.Common; using Hangfire; using Hangfire.Common; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using NUnit.Framework; +using Shouldly; namespace EventFlow.Hangfire.Tests.Integration { @@ -113,7 +112,7 @@ public async Task AsynchronousSubscribesGetInvoked() // Assert var receivedPingId = await Task.Run(() => _testAsynchronousSubscriber.PingIds.Take(), cts.Token).ConfigureAwait(false); - receivedPingId.Should().IsSameOrEqualTo(pingId); + receivedPingId.ShouldBe(pingId); } [Test] @@ -165,10 +164,10 @@ private async Task ValidateScheduleHappens(Func s.Name, s => s); // Assert - sqlScripts.Should().HaveCount(2); - sqlScripts.Should().ContainKey("EventStores.Scripts.0001 - Create table EventFlow.sql"); - sqlScripts.Should().ContainKey("EventStores.Scripts.0002 - Create eventdatamodel_list_type.sql"); + sqlScripts.Count.ShouldBe(2); + sqlScripts.ShouldContainKey("EventStores.Scripts.0001 - Create table EventFlow.sql"); + sqlScripts.ShouldContainKey("EventStores.Scripts.0002 - Create eventdatamodel_list_type.sql"); } } } \ No newline at end of file diff --git a/Source/EventFlow.MsSql.Tests/IntegrationTests/IdentityIndexFragmentationTests.cs b/Source/EventFlow.MsSql.Tests/IntegrationTests/IdentityIndexFragmentationTests.cs index 28b2d170e..d755e3f87 100644 --- a/Source/EventFlow.MsSql.Tests/IntegrationTests/IdentityIndexFragmentationTests.cs +++ b/Source/EventFlow.MsSql.Tests/IntegrationTests/IdentityIndexFragmentationTests.cs @@ -28,8 +28,8 @@ using EventFlow.MsSql.Tests.Extensions; using EventFlow.TestHelpers; using EventFlow.TestHelpers.MsSql; -using FluentAssertions; using NUnit.Framework; +using Shouldly; // ReSharper disable StringLiteralTypo @@ -56,7 +56,7 @@ public void VerifyIdentityHasThereLittleFragmentationUsingString() // Assert var fragmentation = GetIndexFragmentation("IndexFragmentationString"); - fragmentation.Should().BeLessThan(10); + fragmentation.ShouldBeLessThan(10); } @@ -77,7 +77,7 @@ public void SanityIntLowFragmentationStoredInGuid() // Assert var fragmentation = GetIndexFragmentation("IndexFragmentationString"); - fragmentation.Should().BeLessThan(10); + fragmentation.ShouldBeLessThan(10); } [Test] @@ -97,7 +97,7 @@ public void SanityIntAsHexLowFragmentationStoredInGuid() // Assert var fragmentation = GetIndexFragmentation("IndexFragmentationString"); - fragmentation.Should().BeLessThan(10); + fragmentation.ShouldBeLessThan(10); } @@ -109,7 +109,7 @@ public void SanityCombYieldsLowFragmentationStoredInGuid() // Assert var fragmentation = GetIndexFragmentation("IndexFragmentationGuid"); - fragmentation.Should().BeLessThan(10); + fragmentation.ShouldBeLessThan(10); } [Test] @@ -120,7 +120,7 @@ public void SanityCombYieldsHighFragmentationStoredInString() // Assert var fragmentation = GetIndexFragmentation("IndexFragmentationString"); - fragmentation.Should().BeGreaterThan(90); + fragmentation.ShouldBeGreaterThan(90); } [Test] @@ -131,7 +131,7 @@ public void SanityGuidIdentityYieldsHighFragmentationStoredInString() // Assert var fragmentation = GetIndexFragmentation("IndexFragmentationString"); - fragmentation.Should().BeGreaterThan(30); // closer to 100 in reality + fragmentation.ShouldBeGreaterThan(30); // closer to 100 in reality } [Test] @@ -142,7 +142,7 @@ public void SanityGuidIdentityYieldsHighFragmentationStoredInGuid() // Assert var fragmentation = GetIndexFragmentation("IndexFragmentationGuid"); - fragmentation.Should().BeGreaterThan(30); // closer to 100 in reality + fragmentation.ShouldBeGreaterThan(30); // closer to 100 in reality } public void InsertRows(Func generator, int count, string table) diff --git a/Source/EventFlow.MsSql.Tests/IntegrationTests/ReadStores/ReadModels/MultipleMsSqlDatabasesTests.cs b/Source/EventFlow.MsSql.Tests/IntegrationTests/ReadStores/ReadModels/MultipleMsSqlDatabasesTests.cs index b7ac561f5..1f0879522 100644 --- a/Source/EventFlow.MsSql.Tests/IntegrationTests/ReadStores/ReadModels/MultipleMsSqlDatabasesTests.cs +++ b/Source/EventFlow.MsSql.Tests/IntegrationTests/ReadStores/ReadModels/MultipleMsSqlDatabasesTests.cs @@ -35,9 +35,9 @@ using EventFlow.TestHelpers; using EventFlow.TestHelpers.Extensions; using EventFlow.TestHelpers.MsSql; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.MsSql.Tests.IntegrationTests.ReadStores.ReadModels { @@ -120,10 +120,10 @@ public async Task MultipleDatabases() var fetchedMagicReadModels = _readModelDatabase.Query( "SELECT * FROM [ReadModel-Magic] WHERE [MagicId] = @Id", new { Id = magicId.Value }); - fetchedMagicReadModels.Should().HaveCount(1); + fetchedMagicReadModels.Count.ShouldBe(1); var fetchedMagicReadModel = fetchedMagicReadModels.Single(); - fetchedMagicReadModel.Message.Should().Be(expectedMessage); - fetchedMagicReadModel.Version.Should().Be(2); + fetchedMagicReadModel.Message.ShouldBe(expectedMessage); + fetchedMagicReadModel.Version.ShouldBe(2); } public class MagicId : Identity diff --git a/Source/EventFlow.MsSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresMsSqlTests.cs b/Source/EventFlow.MsSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresMsSqlTests.cs index a1cd853ae..44bc43224 100644 --- a/Source/EventFlow.MsSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresMsSqlTests.cs +++ b/Source/EventFlow.MsSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresMsSqlTests.cs @@ -23,8 +23,8 @@ using System.Linq; using EventFlow.MsSql.SnapshotStores; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.MsSql.Tests.IntegrationTests.SnapshotStores { @@ -38,8 +38,8 @@ public void GetSqlScripts() var sqlScripts = EventFlowSnapshotStoresMsSql.GetSqlScripts().ToDictionary(s => s.Name, s => s); // Assert - sqlScripts.Should().HaveCount(1); - sqlScripts.Should().ContainKey("SnapshotStores.Scripts.0001 - Create EventFlowSnapshots.sql"); + sqlScripts.Count.ShouldBe(1); + sqlScripts.ShouldContainKey("SnapshotStores.Scripts.0001 - Create EventFlowSnapshots.sql"); } } } \ No newline at end of file diff --git a/Source/EventFlow.PostgreSql.Tests/IntegrationTests/EventStores/EventFlowEventStoresPostgresSqlTests.cs b/Source/EventFlow.PostgreSql.Tests/IntegrationTests/EventStores/EventFlowEventStoresPostgresSqlTests.cs index 4ebf0e448..50fe07979 100644 --- a/Source/EventFlow.PostgreSql.Tests/IntegrationTests/EventStores/EventFlowEventStoresPostgresSqlTests.cs +++ b/Source/EventFlow.PostgreSql.Tests/IntegrationTests/EventStores/EventFlowEventStoresPostgresSqlTests.cs @@ -23,8 +23,8 @@ using System.Linq; using EventFlow.PostgreSql.EventStores; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.PostgreSql.Tests.IntegrationTests.EventStores { @@ -38,9 +38,9 @@ public void GetSqlScripts() var sqlScripts = EventFlowEventStoresPostgreSql.GetSqlScripts().ToDictionary(s => s.Name, s => s); // Assert - sqlScripts.Should().HaveCount(2); - sqlScripts.Should().ContainKey("EventStores.Scripts.0001 - Create table EventFlow.sql"); - sqlScripts.Should().ContainKey("EventStores.Scripts.0002 - Create eventdatamodel_list_type.sql"); + sqlScripts.Count.ShouldBe(2); + sqlScripts.ShouldContainKey("EventStores.Scripts.0001 - Create table EventFlow.sql"); + sqlScripts.ShouldContainKey("EventStores.Scripts.0002 - Create eventdatamodel_list_type.sql"); } } } \ No newline at end of file diff --git a/Source/EventFlow.PostgreSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresPostgresSqlTests.cs b/Source/EventFlow.PostgreSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresPostgresSqlTests.cs index b6abfaa6f..9ef62d52a 100644 --- a/Source/EventFlow.PostgreSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresPostgresSqlTests.cs +++ b/Source/EventFlow.PostgreSql.Tests/IntegrationTests/SnapshotStores/EventFlowSnapshotStoresPostgresSqlTests.cs @@ -23,8 +23,8 @@ using System.Linq; using EventFlow.PostgreSql.SnapshotStores; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.PostgreSql.Tests.IntegrationTests.SnapshotStores { @@ -38,8 +38,8 @@ public void GetSqlScripts() var sqlScripts = EventFlowSnapshotStoresPostgreSql.GetSqlScripts().ToDictionary(s => s.Name, s => s); // Assert - sqlScripts.Should().HaveCount(1); - sqlScripts.Should().ContainKey("SnapshotStores.Scripts.0001 - Create EventFlowSnapshots.sql"); + sqlScripts.Count.ShouldBe(1); + sqlScripts.ShouldContainKey("SnapshotStores.Scripts.0001 - Create EventFlowSnapshots.sql"); } } } \ No newline at end of file diff --git a/Source/EventFlow.RabbitMQ.Tests/Integration/RabbitMqTests.cs b/Source/EventFlow.RabbitMQ.Tests/Integration/RabbitMqTests.cs index 09759f67f..aef439d1c 100644 --- a/Source/EventFlow.RabbitMQ.Tests/Integration/RabbitMqTests.cs +++ b/Source/EventFlow.RabbitMQ.Tests/Integration/RabbitMqTests.cs @@ -36,11 +36,11 @@ using EventFlow.TestHelpers.Aggregates.Events; using EventFlow.TestHelpers.Aggregates.Queries; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using NUnit.Framework; +using Shouldly; namespace EventFlow.RabbitMQ.Tests.Integration { @@ -83,14 +83,14 @@ public async Task Scenario() await commandBus.PublishAsync(new ThingyPingCommand(ThingyId.New, pingId), _timeout.Token).ConfigureAwait(false); var rabbitMqMessage = consumer.GetMessages(TimeSpan.FromMinutes(1)).Single(); - rabbitMqMessage.Exchange.Value.Should().Be(exchange.Value); - rabbitMqMessage.RoutingKey.Value.Should().Be("eventflow.domainevent.thingy.thingy-ping.1"); + rabbitMqMessage.Exchange.Value.ShouldBe(exchange.Value); + rabbitMqMessage.RoutingKey.Value.ShouldBe("eventflow.domainevent.thingy.thingy-ping.1"); var pingEvent = (IDomainEvent)eventJsonSerializer.Deserialize( rabbitMqMessage.Message, new Metadata(rabbitMqMessage.Headers)); - pingEvent.AggregateEvent.PingId.Should().Be(pingId); + pingEvent.AggregateEvent.PingId.ShouldBe(pingId); } } @@ -116,8 +116,8 @@ public async Task PublisherPerformance() await Task.WhenAll(tasks).ConfigureAwait(false); var rabbitMqMessages = consumer.GetMessages(TimeSpan.FromMinutes(1), totalMessageCount); - rabbitMqMessages.Should().HaveCount(totalMessageCount); - exceptions.Should().BeEmpty(); + rabbitMqMessages.Count.ShouldBe(totalMessageCount); + exceptions.ShouldBeEmpty(); } } diff --git a/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj b/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj index a8c2dc13f..6bcd904fb 100644 --- a/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj +++ b/Source/EventFlow.TestHelpers/EventFlow.TestHelpers.csproj @@ -18,12 +18,12 @@ - + diff --git a/Source/EventFlow.TestHelpers/LoggerMock.cs b/Source/EventFlow.TestHelpers/LoggerMock.cs index bd99c161d..9741e5997 100644 --- a/Source/EventFlow.TestHelpers/LoggerMock.cs +++ b/Source/EventFlow.TestHelpers/LoggerMock.cs @@ -25,8 +25,8 @@ using System.Collections.Generic; using System.Linq; using EventFlow.Core; -using FluentAssertions; using Microsoft.Extensions.Logging; +using Shouldly; namespace EventFlow.TestHelpers { @@ -79,7 +79,7 @@ public void VerifyNoProblems() var messages = Logs(LogLevel.Critical, LogLevel.Error) .Select(m => m.Message) .ToList(); - messages.Should().BeEmpty(string.Join(", ", messages)); + messages.ShouldBeEmpty(string.Join(", ", messages)); } public void VerifyProblemLogged(params Exception[] expectedExceptions) @@ -87,7 +87,11 @@ public void VerifyProblemLogged(params Exception[] expectedExceptions) var exceptions = Logs(LogLevel.Error, LogLevel.Critical) .Select(m => m.Exception) .ToList(); - exceptions.Should().AllBeEquivalentTo(expectedExceptions); + + foreach (var exception in exceptions) + { + exception.ShouldBeOneOf(expectedExceptions); + } } public IReadOnlyCollection Logs(params LogLevel[] logLevels) diff --git a/Source/EventFlow.TestHelpers/Suites/TestSuiteForEventStore.cs b/Source/EventFlow.TestHelpers/Suites/TestSuiteForEventStore.cs index 73e7d43fe..db04442de 100644 --- a/Source/EventFlow.TestHelpers/Suites/TestSuiteForEventStore.cs +++ b/Source/EventFlow.TestHelpers/Suites/TestSuiteForEventStore.cs @@ -37,10 +37,10 @@ using EventFlow.TestHelpers.Aggregates.Events; using EventFlow.TestHelpers.Aggregates.ValueObjects; using EventFlow.TestHelpers.Extensions; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; +using Shouldly; namespace EventFlow.TestHelpers.Suites { @@ -56,8 +56,8 @@ public async Task NewAggregateCanBeLoaded() var testAggregate = await LoadAggregateAsync(ThingyId.New); // Assert - testAggregate.Should().NotBeNull(); - testAggregate.IsNew.Should().BeTrue(); + testAggregate.ShouldNotBeNull(); + testAggregate.IsNew.ShouldBeTrue(); } [Test] @@ -72,16 +72,16 @@ public async Task EventsCanBeStored() var domainEvents = await testAggregate.CommitAsync(EventStore, SnapshotStore, SourceId.New, CancellationToken.None); // Assert - domainEvents.Count.Should().Be(1); + domainEvents.Count.ShouldBe(1); var pingEvent = domainEvents.Single() as IDomainEvent; - pingEvent.Should().NotBeNull(); - pingEvent.AggregateIdentity.Should().Be(id); - pingEvent.AggregateSequenceNumber.Should().Be(1); - pingEvent.AggregateType.Should().Be(typeof(ThingyAggregate)); - pingEvent.EventType.Should().Be(typeof(ThingyPingEvent)); - pingEvent.Timestamp.Should().NotBe(default); - pingEvent.Metadata.Count.Should().BeGreaterThan(0); - pingEvent.Metadata.SourceId.IsNone().Should().BeFalse(); + pingEvent.ShouldNotBeNull(); + pingEvent.AggregateIdentity.ShouldBe(id); + pingEvent.AggregateSequenceNumber.ShouldBe(1); + pingEvent.AggregateType.ShouldBe(typeof(ThingyAggregate)); + pingEvent.EventType.ShouldBe(typeof(ThingyPingEvent)); + pingEvent.Timestamp.ShouldNotBe(default); + pingEvent.Metadata.Count.ShouldBeGreaterThan(0); + pingEvent.Metadata.SourceId.IsNone().ShouldBeFalse(); } [Test] @@ -97,10 +97,10 @@ public async Task AggregatesCanBeLoaded() var loadedTestAggregate = await LoadAggregateAsync(id); // Assert - loadedTestAggregate.Should().NotBeNull(); - loadedTestAggregate.IsNew.Should().BeFalse(); - loadedTestAggregate.Version.Should().Be(1); - loadedTestAggregate.PingsReceived.Count.Should().Be(1); + loadedTestAggregate.ShouldNotBeNull(); + loadedTestAggregate.IsNew.ShouldBeFalse(); + loadedTestAggregate.Version.ShouldBe(1); + loadedTestAggregate.PingsReceived.Count.ShouldBe(1); } [Test] @@ -118,7 +118,7 @@ public async Task EventsCanContainUnicodeCharacters() var loadedTestAggregate = await LoadAggregateAsync(id); // Assert - loadedTestAggregate.Messages.Single().Message.Should().Be("😉"); + loadedTestAggregate.Messages.Single().Message.ShouldBe("😉"); } [Test] @@ -140,8 +140,8 @@ public async Task AggregateEventStreamsAreSeperate() aggregate2 = await LoadAggregateAsync(id2); // Assert - aggregate1.Version.Should().Be(1); - aggregate2.Version.Should().Be(2); + aggregate1.Version.ShouldBe(1); + aggregate2.Version.ShouldBe(2); } [Test] @@ -167,7 +167,7 @@ public async Task DomainEventCanBeLoaded() CancellationToken.None); // Assert - domainEvents.DomainEvents.Count.Should().BeGreaterOrEqualTo(2); + domainEvents.DomainEvents.Count.ShouldBeGreaterThanOrEqualTo(2); } [Test] @@ -181,10 +181,10 @@ public async Task LoadingOfEventsCanStartLater() var domainEvents = await EventStore.LoadEventsAsync(id, 3, CancellationToken.None); // Assert - domainEvents.Should().HaveCount(3); - domainEvents.ElementAt(0).AggregateSequenceNumber.Should().Be(3); - domainEvents.ElementAt(1).AggregateSequenceNumber.Should().Be(4); - domainEvents.ElementAt(2).AggregateSequenceNumber.Should().Be(5); + domainEvents.Count.ShouldBe(3); + domainEvents.ElementAt(0).AggregateSequenceNumber.ShouldBe(3); + domainEvents.ElementAt(1).AggregateSequenceNumber.ShouldBe(4); + domainEvents.ElementAt(2).AggregateSequenceNumber.ShouldBe(5); } [Test] @@ -198,9 +198,9 @@ public async Task LoadingOfEventsCanStartLaterAndStopEarlier() var domainEvents = await EventStore.LoadEventsAsync(id, 3, 4, CancellationToken.None); // Assert - domainEvents.Should().HaveCount(2); - domainEvents.ElementAt(0).AggregateSequenceNumber.Should().Be(3); - domainEvents.ElementAt(1).AggregateSequenceNumber.Should().Be(4); + domainEvents.Count.ShouldBe(2); + domainEvents.ElementAt(0).AggregateSequenceNumber.ShouldBe(3); + domainEvents.ElementAt(1).AggregateSequenceNumber.ShouldBe(4); } [Test] @@ -219,7 +219,7 @@ public async Task AggregateCanHaveMultipleCommits() aggregate = await LoadAggregateAsync(id); // Assert - aggregate.PingsReceived.Count.Should().Be(2); + aggregate.PingsReceived.Count.ShouldBe(2); } [Test] @@ -237,9 +237,9 @@ await CommandBus.PublishAsync( // Assert var aggregate = await LoadAggregateAsync(id); - aggregate.UpgradableEventV1Received.Should().Be(0); - aggregate.UpgradableEventV2Received.Should().Be(0); - aggregate.UpgradableEventV3Received.Should().Be(version1 + version2 + version3); + aggregate.UpgradableEventV1Received.ShouldBe(0); + aggregate.UpgradableEventV2Received.ShouldBe(0); + aggregate.UpgradableEventV3Received.ShouldBe(version1 + version2 + version3); } [Test] @@ -262,8 +262,8 @@ public async Task AggregateEventStreamsCanBeDeleted() // Assert aggregate1 = await LoadAggregateAsync(id1); aggregate2 = await LoadAggregateAsync(id2); - aggregate1.Version.Should().Be(1); - aggregate2.Version.Should().Be(0); + aggregate1.Version.ShouldBe(1); + aggregate2.Version.ShouldBe(0); } [Test] @@ -294,7 +294,7 @@ public async Task NextPositionIsIdOfNextEvent() CancellationToken.None); // Assert - domainEvents.NextGlobalPosition.Value.Should().NotBe(string.Empty); + domainEvents.NextGlobalPosition.Value.ShouldNotBe(string.Empty); } [Test] @@ -317,8 +317,8 @@ public async Task LoadingFirstPageShouldLoadCorrectEvents() CancellationToken.None); // Assert - domainEvents.DomainEvents.OfType>().Should().Contain(e => e.AggregateEvent.PingId == pingIds[0]); - domainEvents.DomainEvents.OfType>().Should().Contain(e => e.AggregateEvent.PingId == pingIds[1]); + domainEvents.DomainEvents.OfType>().ShouldContain(e => e.AggregateEvent.PingId == pingIds[0]); + domainEvents.DomainEvents.OfType>().ShouldContain(e => e.AggregateEvent.PingId == pingIds[1]); } [Test] @@ -353,13 +353,13 @@ public async Task AggregatesCanUpdatedAfterOptimisticConcurrency() // Act aggregate1 = await LoadAggregateAsync(id); - aggregate1.PingsReceived.Single().Should().Be(pingId1); + aggregate1.PingsReceived.Single().ShouldBe(pingId1); aggregate1.Ping(pingId2); await aggregate1.CommitAsync(EventStore, SnapshotStore, SourceId.New, CancellationToken.None); // Assert aggregate1 = await LoadAggregateAsync(id); - aggregate1.PingsReceived.Should().BeEquivalentTo(new[] {pingId1, pingId2}); + aggregate1.PingsReceived.SequenceEqual(new[] { pingId1, pingId2 }).ShouldBeTrue(); } [Test] @@ -388,7 +388,7 @@ await commandBus.PublishAsync( // Assert var aggregate = await LoadAggregateAsync(id); - aggregate.PingsReceived.Should().BeEquivalentTo(new []{pingId1, pingId2}); + aggregate.PingsReceived.SequenceEqual(new[] { pingId1, pingId2 }).ShouldBeTrue(); } [Test] @@ -404,8 +404,8 @@ await CommandBus.PublishAsync( ; // Assert - PublishedDomainEvents.Count.Should().Be(10); - PublishedDomainEvents.Select(d => d.AggregateSequenceNumber).Should().BeEquivalentTo(Enumerable.Range(1, 10)); + PublishedDomainEvents.Count.ShouldBe(10); + PublishedDomainEvents.Select(d => d.AggregateSequenceNumber).SequenceEqual(Enumerable.Range(1, 10)).ShouldBeTrue(); } [Test] @@ -425,8 +425,8 @@ await CommandBus.PublishAsync( ; // Assert - PublishedDomainEvents.Count.Should().Be(10); - PublishedDomainEvents.Select(d => d.AggregateSequenceNumber).Should().BeEquivalentTo(Enumerable.Range(11, 10)); + PublishedDomainEvents.Count.ShouldBe(10); + PublishedDomainEvents.Select(d => d.AggregateSequenceNumber).SequenceEqual(Enumerable.Range(11, 10)).ShouldBeTrue(); } [Test] @@ -447,18 +447,20 @@ public virtual async Task LoadAllEventsAsyncFindsEventsAfterLargeGaps() var idsWithGap = ids.Where(i => !removedIds.Contains(i)); foreach (var id in removedIds) { - await EventPersistence.DeleteEventsAsync(id, CancellationToken.None) - ; + await EventPersistence.DeleteEventsAsync(id, CancellationToken.None); } // Act var result = await EventStore - .LoadAllEventsAsync(GlobalPosition.Start, 5, new EventUpgradeContext(), CancellationToken.None) - ; + .LoadAllEventsAsync(GlobalPosition.Start, 5, new EventUpgradeContext(), CancellationToken.None); // Assert - var domainEventIds = result.DomainEvents.Select(d => d.GetIdentity()); - domainEventIds.Should().Contain(idsWithGap); + var domainEventIds = result.DomainEvents.Select(d => d.GetIdentity()).ToList(); + + foreach (var id in idsWithGap) + { + domainEventIds.ShouldContain(id); + } } [SetUp] @@ -498,7 +500,7 @@ private static async Task ThrowsExceptionAsync(Func action) } } - wasCorrectException.Should().BeTrue("Action was expected to throw exception {0}", typeof(TException).PrettyPrint()); + wasCorrectException.ShouldBeTrue($"Action was expected to throw exception {typeof(TException).PrettyPrint()}"); } } } diff --git a/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs b/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs index 87844eeca..e7fee737a 100644 --- a/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs +++ b/Source/EventFlow.TestHelpers/Suites/TestSuiteForReadModelStore.cs @@ -36,10 +36,10 @@ using AutoFixture; using EventFlow.Extensions; using EventFlow.TestHelpers.Aggregates.Events; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NUnit.Framework; +using Shouldly; using EventId = EventFlow.Aggregates.EventId; namespace EventFlow.TestHelpers.Suites @@ -56,7 +56,7 @@ public async Task NonExistingReadModelReturnsNull() var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id)).ConfigureAwait(false); // Assert - readModel.Should().BeNull(); + readModel.ShouldBeNull(); } [Test] @@ -70,8 +70,8 @@ public async Task ReadModelReceivesEvent() var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id)).ConfigureAwait(false); // Assert - readModel.Should().NotBeNull(); - readModel.PingsReceived.Should().Be(5); + readModel.ShouldNotBeNull(); + readModel.PingsReceived.ShouldBe(5); } [Test] @@ -84,7 +84,7 @@ public async Task InitialReadModelVersionIsNull() var version = await QueryProcessor.ProcessAsync(new ThingyGetVersionQuery(thingyId)).ConfigureAwait(false); // Assert - version.Should().NotHaveValue(); + version.ShouldBeNull(); } [Test] @@ -99,7 +99,7 @@ public async Task ReadModelVersionShouldMatchAggregate() var version = await QueryProcessor.ProcessAsync(new ThingyGetVersionQuery(thingyId)).ConfigureAwait(false); // Assert - version.Should().Be((long)version); + version.ShouldBe((long)version); } [Test] @@ -115,8 +115,8 @@ public async Task CanStoreMultipleMessages() var returnedThingyMessages = await QueryProcessor.ProcessAsync(new ThingyGetMessagesQuery(thingyId)).ConfigureAwait(false); // Assert - returnedThingyMessages.Should().HaveCount(thingyMessages.Count); - returnedThingyMessages.Should().BeEquivalentTo(thingyMessages); + returnedThingyMessages.Count.ShouldBe(thingyMessages.Count); + returnedThingyMessages.ShouldBe(thingyMessages, ignoreOrder: true); } [Test] @@ -137,8 +137,8 @@ await CommandBus.PublishAsync(new ThingyImportCommand( var thingy = await QueryProcessor.ProcessAsync(new ThingyGetQuery(thingyId)).ConfigureAwait(false); // Assert - thingy.PingsReceived.Should().Be(pingIds.Count); - returnedThingyMessages.Should().BeEquivalentTo(thingyMessages); + thingy.PingsReceived.ShouldBe(pingIds.Count); + returnedThingyMessages.ShouldBe(thingyMessages, ignoreOrder: true); } [Test] @@ -153,7 +153,7 @@ public async Task PurgeRemovesReadModels() var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id)).ConfigureAwait(false); // Assert - readModel.Should().BeNull(); + readModel.ShouldBeNull(); } [Test] @@ -166,8 +166,8 @@ public async Task DeleteRemovesSpecificReadModel() await PublishPingCommandAsync(id2).ConfigureAwait(false); var readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false); var readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); - readModel1.Should().NotBeNull(); - readModel2.Should().NotBeNull(); + readModel1.ShouldNotBeNull(); + readModel2.ShouldNotBeNull(); // Act await ReadModelPopulator.DeleteAsync( @@ -179,8 +179,8 @@ await ReadModelPopulator.DeleteAsync( // Assert readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false); readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); - readModel1.Should().BeNull(); - readModel2.Should().NotBeNull(); + readModel1.ShouldBeNull(); + readModel2.ShouldNotBeNull(); } [Test] @@ -200,8 +200,8 @@ public async Task RePopulateHandlesManyAggregates() var readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false); var readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); - readModel1.PingsReceived.Should().Be(3); - readModel2.PingsReceived.Should().Be(5); + readModel1.PingsReceived.ShouldBe(3); + readModel2.PingsReceived.ShouldBe(5); } [Test] @@ -220,7 +220,7 @@ public async Task RePopulateHandlesDeletedAggregate() // Assert var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); - readModel.PingsReceived.Should().Be(5); + readModel.PingsReceived.ShouldBe(5); } [Test] @@ -236,8 +236,8 @@ public async Task PopulateCreatesReadModels() var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id)).ConfigureAwait(false); // Assert - readModel.Should().NotBeNull(); - readModel.PingsReceived.Should().Be(2); + readModel.ShouldNotBeNull(); + readModel.PingsReceived.ShouldBe(2); } [Test] @@ -257,7 +257,7 @@ await PublishPingCommandAsync(id).ConfigureAwait(false) // Assert var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id)).ConfigureAwait(false); - readModel.PingsReceived.Should().Be(pingIds.Count); + readModel.PingsReceived.ShouldBe(pingIds.Count); } } @@ -290,7 +290,7 @@ public virtual async Task OptimisticConcurrencyCheck() // Assert var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id), cts.Token).ConfigureAwait(false); - readModel.PingsReceived.Should().Be(3); + readModel.PingsReceived.ShouldBe(3); } } @@ -304,8 +304,8 @@ public async Task MarkingForDeletionRemovesSpecificReadModel() await PublishPingCommandAsync(id2).ConfigureAwait(false); var readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false); var readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); - readModel1.Should().NotBeNull(); - readModel2.Should().NotBeNull(); + readModel1.ShouldNotBeNull(); + readModel2.ShouldNotBeNull(); // Act await CommandBus.PublishAsync(new ThingyDeleteCommand(id1), CancellationToken.None); @@ -313,8 +313,8 @@ public async Task MarkingForDeletionRemovesSpecificReadModel() // Assert readModel1 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id1)).ConfigureAwait(false); readModel2 = await QueryProcessor.ProcessAsync(new ThingyGetQuery(id2)).ConfigureAwait(false); - readModel1.Should().BeNull(); - readModel2.Should().NotBeNull(); + readModel1.ShouldBeNull(); + readModel2.ShouldNotBeNull(); } [Test] @@ -330,8 +330,8 @@ public async Task CanStoreMessageHistory() var returnedThingyMessages = await QueryProcessor.ProcessAsync(new ThingyGetMessagesQuery(thingyId)).ConfigureAwait(false); // Assert - returnedThingyMessages.Should().HaveCount(thingyMessages.Count); - returnedThingyMessages.Should().BeEquivalentTo(thingyMessages); + returnedThingyMessages.Count.ShouldBe(thingyMessages.Count); + returnedThingyMessages.ShouldBe(thingyMessages, ignoreOrder: true); } [TestCase(true, true)] @@ -372,9 +372,9 @@ await readStoreManager.UpdateReadStoresAsync( // Assert var returnedThingyMessages = await QueryProcessor.ProcessAsync(new ThingyGetMessagesQuery(thingyId)).ConfigureAwait(false); - returnedThingyMessages.Should().HaveCount(1); + returnedThingyMessages.Count.ShouldBe(1); var readModel = await QueryProcessor.ProcessAsync(new ThingyGetQuery(thingyId)).ConfigureAwait(false); - readModel.PingsReceived.Should().Be(1); + readModel.PingsReceived.ShouldBe(1); } private class WaitState diff --git a/Source/EventFlow.TestHelpers/Suites/TestSuiteForScheduler.cs b/Source/EventFlow.TestHelpers/Suites/TestSuiteForScheduler.cs index 1b988ef71..55dee81df 100644 --- a/Source/EventFlow.TestHelpers/Suites/TestSuiteForScheduler.cs +++ b/Source/EventFlow.TestHelpers/Suites/TestSuiteForScheduler.cs @@ -33,10 +33,9 @@ using EventFlow.TestHelpers.Aggregates.Commands; using EventFlow.TestHelpers.Aggregates.Events; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; -using FluentAssertions.Common; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.TestHelpers.Suites { @@ -81,7 +80,7 @@ public async Task AsynchronousSubscribesGetInvoked() // Assert var receivedPingId = await Task.Run(() => _testAsynchronousSubscriber.PingIds.Take(), cts.Token).ConfigureAwait(false); - receivedPingId.Should().IsSameOrEqualTo(pingId); + receivedPingId.ShouldBe(pingId); } } diff --git a/Source/EventFlow.TestHelpers/Suites/TestSuiteForSnapshotStore.cs b/Source/EventFlow.TestHelpers/Suites/TestSuiteForSnapshotStore.cs index 91e1d94fb..195560f04 100644 --- a/Source/EventFlow.TestHelpers/Suites/TestSuiteForSnapshotStore.cs +++ b/Source/EventFlow.TestHelpers/Suites/TestSuiteForSnapshotStore.cs @@ -32,9 +32,9 @@ using EventFlow.TestHelpers.Aggregates.Commands; using EventFlow.TestHelpers.Aggregates.Snapshots; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using Newtonsoft.Json; using NUnit.Framework; +using Shouldly; namespace EventFlow.TestHelpers.Suites { @@ -51,7 +51,7 @@ public async Task GetSnapshotAsync_NoneExistingSnapshotReturnsNull() .ConfigureAwait(false); // Assert - committedSnapshot.Should().BeNull(); + committedSnapshot.ShouldBeNull(); } [Test] @@ -89,7 +89,7 @@ public async Task NoSnapshotsAreCreatedWhenCommittingFewEvents() var thingySnapshot = await LoadSnapshotAsync(thingyId).ConfigureAwait(false); // Assert - thingySnapshot.Should().BeNull(); + thingySnapshot.ShouldBeNull(); } [Test] @@ -104,8 +104,8 @@ public async Task SnapshotIsCreatedWhenCommittingManyEvents() var thingySnapshot = await LoadSnapshotAsync(thingyId).ConfigureAwait(false); // Assert - thingySnapshot.Should().NotBeNull(); - thingySnapshot.PingsReceived.Count.Should().Be(ThingyAggregate.SnapshotEveryVersion); + thingySnapshot.ShouldNotBeNull(); + thingySnapshot.PingsReceived.Count.ShouldBe(ThingyAggregate.SnapshotEveryVersion); } [TestCase(1)] @@ -121,7 +121,7 @@ public async Task DuplicateOperationExceptionIsThrown(int index) // Validate var thingySnapshot = await LoadSnapshotAsync(thingyId).ConfigureAwait(false); - thingySnapshot.PingsReceived.Should().HaveCount(ThingyAggregate.SnapshotEveryVersion); + thingySnapshot.PingsReceived.Count.ShouldBe(ThingyAggregate.SnapshotEveryVersion); // Act var command = new ThingyPingCommand(thingyId, sourceIds[index], PingId.New); @@ -140,8 +140,8 @@ public async Task LoadedAggregateHasCorrectVersionsWhenSnapshotIsApplied() var thingyAggregate = await LoadAggregateAsync(thingyId).ConfigureAwait(false); // Assert - thingyAggregate.Version.Should().Be(pingsSent); - thingyAggregate.SnapshotVersion.GetValueOrDefault().Should().Be(ThingyAggregate.SnapshotEveryVersion); + thingyAggregate.Version.ShouldBe(pingsSent); + thingyAggregate.SnapshotVersion.GetValueOrDefault().ShouldBe(ThingyAggregate.SnapshotEveryVersion); } [Test] @@ -151,9 +151,9 @@ public async Task LoadingNoneExistingSnapshottedAggregateReturnsVersionZeroAndNu var thingyAggregate = await LoadAggregateAsync(A()).ConfigureAwait(false); // Assert - thingyAggregate.Should().NotBeNull(); - thingyAggregate.Version.Should().Be(0); - thingyAggregate.SnapshotVersion.Should().NotHaveValue(); + thingyAggregate.ShouldNotBeNull(); + thingyAggregate.Version.ShouldBe(0); + thingyAggregate.SnapshotVersion.ShouldBeNull(); } [Test] @@ -173,12 +173,12 @@ public async Task OldSnapshotsAreUpgradedToLatestVersionAndHaveCorrectMetadata() .ConfigureAwait(false); // Assert - snapshotContainer.Snapshot.Should().BeOfType(); - snapshotContainer.Metadata.AggregateId.Should().Be(thingyId.Value); - snapshotContainer.Metadata.AggregateName.Should().Be("ThingyAggregate"); - snapshotContainer.Metadata.AggregateSequenceNumber.Should().Be(expectedVersion); - snapshotContainer.Metadata.SnapshotName.Should().Be("thingy"); - snapshotContainer.Metadata.SnapshotVersion.Should().Be(1); + snapshotContainer.Snapshot.ShouldBeOfType(); + snapshotContainer.Metadata.AggregateId.ShouldBe(thingyId.Value); + snapshotContainer.Metadata.AggregateName.ShouldBe("ThingyAggregate"); + snapshotContainer.Metadata.AggregateSequenceNumber.ShouldBe(expectedVersion); + snapshotContainer.Metadata.SnapshotName.ShouldBe("thingy"); + snapshotContainer.Metadata.SnapshotVersion.ShouldBe(1); } [Test] @@ -221,9 +221,10 @@ public async Task OldSnapshotsAreUpgradedToLatestVersionAndAppliedToAggregate() var thingyAggregate = await LoadAggregateAsync(thingyId).ConfigureAwait(false); // Assert - thingyAggregate.Version.Should().Be(expectedVersion); - thingyAggregate.PingsReceived.Should().BeEquivalentTo(pingIds); - thingyAggregate.SnapshotVersions.Should().Contain(new[] {ThingySnapshotVersion.Version1, ThingySnapshotVersion.Version2}); + thingyAggregate.Version.ShouldBe(expectedVersion); + thingyAggregate.PingsReceived.ShouldBe(pingIds, ignoreOrder: true); + thingyAggregate.SnapshotVersions.ShouldContain(ThingySnapshotVersion.Version1); + thingyAggregate.SnapshotVersions.ShouldContain(ThingySnapshotVersion.Version2); } protected override IEventFlowOptions Options(IEventFlowOptions eventFlowOptions) diff --git a/Source/EventFlow.Tests/Exploration/CustomAggregateIdExplorationTest.cs b/Source/EventFlow.Tests/Exploration/CustomAggregateIdExplorationTest.cs index d3938991f..bca593b27 100644 --- a/Source/EventFlow.Tests/Exploration/CustomAggregateIdExplorationTest.cs +++ b/Source/EventFlow.Tests/Exploration/CustomAggregateIdExplorationTest.cs @@ -25,9 +25,9 @@ using EventFlow.Aggregates; using EventFlow.Core; using EventFlow.TestHelpers; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.Exploration { @@ -48,7 +48,7 @@ public async Task AggregatesCanHaveCustomImplementedIdentity() var customAggregate = await aggregateStore.LoadAsync(customId, CancellationToken.None).ConfigureAwait(false); // Assert - customAggregate.Id.Value.Should().Be(customId.Value); + customAggregate.Id.Value.ShouldBe(customId.Value); } } diff --git a/Source/EventFlow.Tests/Exploration/EventUpgradeExplorationTest.cs b/Source/EventFlow.Tests/Exploration/EventUpgradeExplorationTest.cs index a68a13ff0..6b035fc7c 100644 --- a/Source/EventFlow.Tests/Exploration/EventUpgradeExplorationTest.cs +++ b/Source/EventFlow.Tests/Exploration/EventUpgradeExplorationTest.cs @@ -29,9 +29,9 @@ using EventFlow.EventStores; using EventFlow.Extensions; using EventFlow.TestHelpers; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.Exploration { @@ -77,7 +77,7 @@ await aggregateStore.UpdateAsync( var aggregate = await aggregateStore.LoadAsync( id, CancellationToken.None); - aggregate.V2Applied.Should().BeTrue(); + aggregate.V2Applied.ShouldBeTrue(); } public class SourceId : ISourceId diff --git a/Source/EventFlow.Tests/Exploration/RegisterSubscribersExplorationTests.cs b/Source/EventFlow.Tests/Exploration/RegisterSubscribersExplorationTests.cs index f89cbf3cf..920f5a856 100644 --- a/Source/EventFlow.Tests/Exploration/RegisterSubscribersExplorationTests.cs +++ b/Source/EventFlow.Tests/Exploration/RegisterSubscribersExplorationTests.cs @@ -34,9 +34,9 @@ using EventFlow.TestHelpers.Aggregates.Events; using EventFlow.TestHelpers.Aggregates.Queries; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.Exploration { @@ -68,7 +68,7 @@ await commandBus.PublishAsync( } // Assert - wasHandled.Should().BeTrue(); + wasHandled.ShouldBeTrue(); } public static IEnumerable> TestCases() diff --git a/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateFactoryTests.cs b/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateFactoryTests.cs index 0820fec3c..bd4f76601 100644 --- a/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateFactoryTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateFactoryTests.cs @@ -26,9 +26,9 @@ using EventFlow.Extensions; using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests.Aggregates { @@ -49,7 +49,7 @@ public async Task CreatesNewAggregateWithIdParameter() var aggregateWithIdParameter = await sut.CreateNewAggregateAsync(id).ConfigureAwait(false); // Assert - aggregateWithIdParameter.Id.Should().Be(id); + aggregateWithIdParameter.Id.ShouldBe(id); } } @@ -65,7 +65,7 @@ public async Task CreatesNewAggregateWithIdAndInterfaceParameters() var aggregateWithIdAndInterfaceParameters = await sut.CreateNewAggregateAsync(ThingyId.New).ConfigureAwait(false); // Assert - aggregateWithIdAndInterfaceParameters.ServiceProvider.Should().BeAssignableTo(); + aggregateWithIdAndInterfaceParameters.ServiceProvider.ShouldBeAssignableTo(); } } @@ -83,7 +83,7 @@ public async Task CreatesNewAggregateWithIdAndTypeParameters() var aggregateWithIdAndTypeParameters = await sut.CreateNewAggregateAsync(ThingyId.New).ConfigureAwait(false); // Assert - aggregateWithIdAndTypeParameters.Pinger.Should().BeOfType(); + aggregateWithIdAndTypeParameters.Pinger.ShouldBeOfType(); } } diff --git a/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateStoreTests.cs b/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateStoreTests.cs index fa15149db..8edc1f0d8 100644 --- a/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateStoreTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/Aggregates/AggregateStoreTests.cs @@ -26,8 +26,8 @@ using EventFlow.TestHelpers.Aggregates; using EventFlow.TestHelpers.Aggregates.Commands; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests.Aggregates { @@ -47,14 +47,14 @@ public async Task ExecutionResultShouldControlEventStore(bool isSuccess, int exp new ThingyMaybePingCommand(thingyId, pingId, isSuccess), CancellationToken.None) .ConfigureAwait(false); - executionResult.IsSuccess.Should().Be(isSuccess); + executionResult.IsSuccess.ShouldBe(isSuccess); // Assert var thingyAggregate = await AggregateStore.LoadAsync( thingyId, CancellationToken.None) .ConfigureAwait(false); - thingyAggregate.Version.Should().Be(expectedAggregateVersion); + thingyAggregate.Version.ShouldBe(expectedAggregateVersion); } } } diff --git a/Source/EventFlow.Tests/IntegrationTests/BackwardCompatibilityTests.cs b/Source/EventFlow.Tests/IntegrationTests/BackwardCompatibilityTests.cs index 5c6f60dc1..5f0dcda65 100644 --- a/Source/EventFlow.Tests/IntegrationTests/BackwardCompatibilityTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/BackwardCompatibilityTests.cs @@ -33,9 +33,9 @@ using EventFlow.TestHelpers.Aggregates.Commands; using EventFlow.TestHelpers.Aggregates.Queries; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests { @@ -71,9 +71,9 @@ public async Task ValidateTestAggregate() var testAggregate = await _aggregateStore.LoadAsync(_thingyId, CancellationToken.None); // Assert - testAggregate.Version.Should().Be(2); - testAggregate.PingsReceived.Should().Contain(PingId.With("95433aa0-11f7-4128-bd5f-18e0ecc4d7c1")); - testAggregate.PingsReceived.Should().Contain(PingId.With("2352d09b-4712-48cc-bb4f-5560d7c52558")); + testAggregate.Version.ShouldBe(2); + testAggregate.PingsReceived.ShouldContain(PingId.With("95433aa0-11f7-4128-bd5f-18e0ecc4d7c1")); + testAggregate.PingsReceived.ShouldContain(PingId.With("2352d09b-4712-48cc-bb4f-5560d7c52558")); } [Test, Explicit] diff --git a/Source/EventFlow.Tests/IntegrationTests/BasicTests.cs b/Source/EventFlow.Tests/IntegrationTests/BasicTests.cs index 2a9bfe38c..28bdb467a 100644 --- a/Source/EventFlow.Tests/IntegrationTests/BasicTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/BasicTests.cs @@ -38,9 +38,9 @@ using EventFlow.TestHelpers.Aggregates.Queries; using EventFlow.TestHelpers.Aggregates.ValueObjects; using EventFlow.Tests.IntegrationTests.ReadStores.ReadModels; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests { @@ -126,10 +126,10 @@ public async Task BasicFlow(IEventFlowOptions eventFlowOptions) .ConfigureAwait(false); // Assert - pingReadModels.Should().HaveCount(2); - testAggregate.DomainErrorAfterFirstReceived.Should().BeTrue(); - testReadModelFromQuery1.DomainErrorAfterFirstReceived.Should().BeTrue(); - testReadModelFromQuery2.Should().NotBeNull(); + pingReadModels.Count.ShouldBe(2); + testAggregate.DomainErrorAfterFirstReceived.ShouldBeTrue(); + testReadModelFromQuery1.DomainErrorAfterFirstReceived.ShouldBeTrue(); + testReadModelFromQuery2.ShouldNotBeNull(); } } diff --git a/Source/EventFlow.Tests/IntegrationTests/CancellationTests.cs b/Source/EventFlow.Tests/IntegrationTests/CancellationTests.cs index c1ad2930a..1d166af68 100644 --- a/Source/EventFlow.Tests/IntegrationTests/CancellationTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/CancellationTests.cs @@ -44,9 +44,9 @@ using EventFlow.TestHelpers.Aggregates.ValueObjects; using EventFlow.TestHelpers.Extensions; using EventFlow.Tests.IntegrationTests.ReadStores.ReadModels; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests { @@ -137,29 +137,29 @@ private List CreateSteps(ThingyId id) CancellationBoundary.BeforeCommittingEvents, _commandHandler.ExecuteCompletionSource, () => Task.FromResult(_commandHandler.HasBeenCalled), - v => v.Should().BeTrue(), - v => v.Should().BeFalse()), + v => v.ShouldBeTrue(), + v => v.ShouldBeFalse()), new Step>( CancellationBoundary.BeforeUpdatingReadStores, _eventPersistence.CommitCompletionSource, () => _eventPersistence.LoadCommittedEventsAsync(id, 0, CancellationToken.None), - v => v.Should().NotBeEmpty(), - v => v.Should().BeEmpty()), + v => v.ShouldNotBeEmpty(), + v => v.ShouldBeEmpty()), new Step>( CancellationBoundary.BeforeNotifyingSubscribers, _readStore.UpdateCompletionSource, () => _readStore.GetAsync(id.ToString(), CancellationToken.None), - v => v.ReadModel.Should().NotBeNull(), - v => v.ReadModel.Should().BeNull()), + v => v.ReadModel.ShouldNotBeNull(), + v => v.ReadModel.ShouldBeNull()), new Step( CancellationBoundary.CancelAlways, _subscriber.HandleCompletionSource, () => Task.FromResult(_subscriber.HasHandled), - v => v.Should().BeTrue(), - v => v.Should().BeFalse()) + v => v.ShouldBeTrue(), + v => v.ShouldBeFalse()) }; return steps; diff --git a/Source/EventFlow.Tests/IntegrationTests/CommandResultTests.cs b/Source/EventFlow.Tests/IntegrationTests/CommandResultTests.cs index 605f2caed..79a06cdf0 100644 --- a/Source/EventFlow.Tests/IntegrationTests/CommandResultTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/CommandResultTests.cs @@ -24,15 +24,14 @@ using System.Threading.Tasks; using EventFlow.Aggregates.ExecutionResults; using EventFlow.Commands; -using EventFlow.Configuration; using EventFlow.Extensions; using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; using EventFlow.TestHelpers.Aggregates.Queries; using EventFlow.Tests.UnitTests.Specifications; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests { @@ -107,14 +106,14 @@ public async Task CommandResult() new TestSuccessResultCommand(ThingyId.New), CancellationToken.None) .ConfigureAwait(false); - success.IsSuccess.Should().BeTrue(); - success.MagicNumber.Should().Be(42); + success.IsSuccess.ShouldBeTrue(); + success.MagicNumber.ShouldBe(42); var failed = await commandBus.PublishAsync( new TestFailedResultCommand(ThingyId.New), CancellationToken.None) .ConfigureAwait(false); - failed.IsSuccess.Should().BeFalse(); + failed.IsSuccess.ShouldBeFalse(); } } } diff --git a/Source/EventFlow.Tests/IntegrationTests/ReadStores/MultipleAggregateReadStoreManagerTests.cs b/Source/EventFlow.Tests/IntegrationTests/ReadStores/MultipleAggregateReadStoreManagerTests.cs index 484211f58..536f553ad 100644 --- a/Source/EventFlow.Tests/IntegrationTests/ReadStores/MultipleAggregateReadStoreManagerTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/ReadStores/MultipleAggregateReadStoreManagerTests.cs @@ -31,9 +31,9 @@ using EventFlow.Queries; using EventFlow.ReadStores; using EventFlow.TestHelpers; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; // ReSharper disable ClassNeverInstantiated.Local @@ -71,9 +71,7 @@ public async Task EventOrdering() new ReadModelByIdQuery(ReadModelId), CancellationToken.None); - readModelAb.Indexes.Should().BeEquivalentTo( - new []{0, 1, 2, 3}, - o => o.WithStrictOrdering()); + readModelAb.Indexes.ShouldBe(new []{0, 1, 2, 3}, ignoreOrder: false); } protected override IServiceProvider Configure(IEventFlowOptions eventFlowOptions) diff --git a/Source/EventFlow.Tests/IntegrationTests/Sagas/AggregateSagaTests.cs b/Source/EventFlow.Tests/IntegrationTests/Sagas/AggregateSagaTests.cs index ced49a553..f36704984 100644 --- a/Source/EventFlow.Tests/IntegrationTests/Sagas/AggregateSagaTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/Sagas/AggregateSagaTests.cs @@ -25,7 +25,6 @@ using System.Threading; using System.Threading.Tasks; using EventFlow.Aggregates; -using EventFlow.Configuration; using EventFlow.Extensions; using EventFlow.Sagas; using EventFlow.Subscribers; @@ -35,10 +34,10 @@ using EventFlow.TestHelpers.Aggregates.Sagas; using EventFlow.TestHelpers.Aggregates.Sagas.Events; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests.Sagas { @@ -54,7 +53,7 @@ public async Task InitialSagaStateIsNew() var thingySaga = await LoadSagaAsync(A()); // Assert - thingySaga.State.Should().Be(SagaState.New); + thingySaga.State.ShouldBe(SagaState.New); } [Test] @@ -68,7 +67,7 @@ public async Task PublishingEventWithoutStartingSagaLeavesItNew() // Assert var thingySaga = await LoadSagaAsync(thingyId); - thingySaga.State.Should().Be(SagaState.New); + thingySaga.State.ShouldBe(SagaState.New); } [Test] @@ -82,7 +81,7 @@ public async Task PublishingEventWithoutStartingDoesntPublishToMainAggregate() // Assert var thingyAggregate = await LoadAggregateAsync(thingyId); - thingyAggregate.Messages.Should().BeEmpty(); + thingyAggregate.Messages.ShouldBeEmpty(); } [Test] @@ -96,7 +95,7 @@ public async Task PublishingCompleteEventWithoutStartingSagaLeavesItNew() // Assert var thingySaga = await LoadSagaAsync(thingyId); - thingySaga.State.Should().Be(SagaState.New); + thingySaga.State.ShouldBe(SagaState.New); } [Test] @@ -110,7 +109,7 @@ public async Task PublishingStartTiggerEventStartsSaga() // Assert var thingySaga = await LoadSagaAsync(thingyId); - thingySaga.State.Should().Be(SagaState.Running); + thingySaga.State.ShouldBe(SagaState.Running); } [Test] @@ -125,7 +124,7 @@ public async Task PublishingStartAndCompleteTiggerEventsCompletesSaga() // Assert var thingySaga = await LoadSagaAsync(thingyId); - thingySaga.State.Should().Be(SagaState.Completed); + thingySaga.State.ShouldBe(SagaState.Completed); } [Test] @@ -158,18 +157,19 @@ public async Task PublishingStartAndCompleteWithPingsResultInCorrectMessages() // Assert - saga var thingySaga = await LoadSagaAsync(thingyId); - thingySaga.State.Should().Be(SagaState.Completed); - thingySaga.PingIdsSinceStarted.Should().BeEquivalentTo(pingsWithRunningSaga); + thingySaga.State.ShouldBe(SagaState.Completed); + thingySaga.PingIdsSinceStarted.ShouldBe(pingsWithRunningSaga, ignoreOrder: true); // Assert - aggregate var thingyAggregate = await LoadAggregateAsync(thingyId); - thingyAggregate.PingsReceived.Should().BeEquivalentTo( - pingsWithNewSaga.Concat(pingsWithRunningSaga).Concat(pingsWithCompletedSaga)); + thingyAggregate.PingsReceived.ShouldBe( + pingsWithNewSaga.Concat(pingsWithRunningSaga).Concat(pingsWithCompletedSaga), + ignoreOrder: true); var receivedSagaPingIds = thingyAggregate.Messages .Select(m => PingId.With(m.Message)) .ToList(); - receivedSagaPingIds.Should().HaveCount(3); - receivedSagaPingIds.Should().BeEquivalentTo(pingsWithRunningSaga); + receivedSagaPingIds.Count.ShouldBe(3); + receivedSagaPingIds.ShouldBe(pingsWithRunningSaga, ignoreOrder: true); } protected override IServiceProvider Configure(IEventFlowOptions eventFlowOptions) diff --git a/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTestClasses.cs b/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTestClasses.cs index f3cb9be51..e3947748c 100644 --- a/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTestClasses.cs +++ b/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTestClasses.cs @@ -28,12 +28,11 @@ using EventFlow.Aggregates; using EventFlow.Aggregates.ExecutionResults; using EventFlow.Commands; -using EventFlow.Configuration; using EventFlow.Core; using EventFlow.Sagas; using EventFlow.ValueObjects; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; +using Shouldly; namespace EventFlow.Tests.IntegrationTests.Sagas { @@ -61,7 +60,7 @@ public InMemorySagaStore( public void UpdateShouldNotHaveBeenCalled() { - this._hasUpdateBeenCalled.Should().BeFalse(); + this._hasUpdateBeenCalled.ShouldBeFalse(); } public override async Task UpdateAsync( diff --git a/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTests.cs b/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTests.cs index ea6dd833f..f040a2bc2 100644 --- a/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/Sagas/AlternativeSagaStoreTests.cs @@ -27,9 +27,9 @@ using EventFlow.Extensions; using EventFlow.Sagas; using EventFlow.TestHelpers; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests.Sagas { @@ -87,9 +87,9 @@ await _commandBus.PublishAsync( var testAggregate = await _aggregateStore.LoadAsync( aggregateId, CancellationToken.None); - testAggregate.As.Should().Be(1); - testAggregate.Bs.Should().Be(1); - testAggregate.Cs.Should().Be(1); + testAggregate.As.ShouldBe(1); + testAggregate.Bs.ShouldBe(1); + testAggregate.Cs.ShouldBe(1); } [Test] @@ -107,9 +107,9 @@ await _commandBus.PublishAsync( var testAggregate = await _aggregateStore.LoadAsync( aggregateId, CancellationToken.None); - testAggregate.As.Should().Be(0); - testAggregate.Bs.Should().Be(1); - testAggregate.Cs.Should().Be(0); + testAggregate.As.ShouldBe(0); + testAggregate.Bs.ShouldBe(1); + testAggregate.Cs.ShouldBe(0); } [Test] diff --git a/Source/EventFlow.Tests/IntegrationTests/Sagas/SagaErrorHandlerTests.cs b/Source/EventFlow.Tests/IntegrationTests/Sagas/SagaErrorHandlerTests.cs index dcbf666b9..efcd5281c 100644 --- a/Source/EventFlow.Tests/IntegrationTests/Sagas/SagaErrorHandlerTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/Sagas/SagaErrorHandlerTests.cs @@ -20,19 +20,18 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -using EventFlow.Configuration; using EventFlow.Sagas; using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; using EventFlow.TestHelpers.Aggregates.Commands; using EventFlow.TestHelpers.Aggregates.Sagas; -using FluentAssertions; using Moq; using NUnit.Framework; using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; +using Shouldly; namespace EventFlow.Tests.IntegrationTests.Sagas { @@ -57,8 +56,8 @@ await CommandBus.PublishAsync(new ThingyThrowExceptionInSagaCommand(thingyId), C }; // Assert - commandPublishAction.Should().Throw() - .WithMessage("Exception thrown (as requested by ThingySagaExceptionRequestedEvent)"); + var exception = await Should.ThrowAsync(commandPublishAction); + exception.Message.ShouldContain("Exception thrown (as requested by ThingySagaExceptionRequestedEvent)"); } [Test] @@ -83,7 +82,7 @@ await CommandBus.PublishAsync(new ThingyThrowExceptionInSagaCommand(thingyId), C }; // Assert - commandPublishAction.Should().NotThrow(); + await Should.NotThrowAsync(commandPublishAction); } protected override IServiceProvider Configure(IEventFlowOptions eventFlowOptions) diff --git a/Source/EventFlow.Tests/IntegrationTests/SeparationTests.cs b/Source/EventFlow.Tests/IntegrationTests/SeparationTests.cs index e2b379dc4..6d138cb16 100644 --- a/Source/EventFlow.Tests/IntegrationTests/SeparationTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/SeparationTests.cs @@ -31,9 +31,9 @@ using EventFlow.TestHelpers.Aggregates.Queries; using EventFlow.TestHelpers.Aggregates.ValueObjects; using EventFlow.TestHelpers.Extensions; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests { @@ -60,7 +60,7 @@ await resolver1.GetRequiredService().PublishAsync( thingyId, CancellationToken.None) .ConfigureAwait(false); - aggregate.IsNew.Should().BeTrue(); + aggregate.IsNew.ShouldBeTrue(); } } diff --git a/Source/EventFlow.Tests/IntegrationTests/ServiceProviderTests.cs b/Source/EventFlow.Tests/IntegrationTests/ServiceProviderTests.cs index f024fc34c..673b0456e 100644 --- a/Source/EventFlow.Tests/IntegrationTests/ServiceProviderTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/ServiceProviderTests.cs @@ -29,9 +29,9 @@ using EventFlow.TestHelpers.Aggregates; using EventFlow.TestHelpers.Aggregates.Commands; using EventFlow.TestHelpers.Aggregates.Queries; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.IntegrationTests { @@ -64,10 +64,8 @@ public async Task ResolverAggregatesFactoryCanResolve() var serviceDependentAggregate = await aggregateFactory.CreateNewAggregateAsync(ThingyId.New).ConfigureAwait(false); // Assert - serviceDependentAggregate.Service.Should() - .NotBeNull() - .And - .BeOfType(); + serviceDependentAggregate.Service.ShouldNotBeNull(); + serviceDependentAggregate.Service.ShouldBeOfType(); } } diff --git a/Source/EventFlow.Tests/IntegrationTests/UnicodeTests.cs b/Source/EventFlow.Tests/IntegrationTests/UnicodeTests.cs index cdb727310..0e8a420c6 100644 --- a/Source/EventFlow.Tests/IntegrationTests/UnicodeTests.cs +++ b/Source/EventFlow.Tests/IntegrationTests/UnicodeTests.cs @@ -31,10 +31,10 @@ using EventFlow.EventStores; using EventFlow.Extensions; using EventFlow.TestHelpers; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NUnit.Framework; +using Shouldly; // ReSharper disable IdentifierTypo // ReSharper disable StringLiteralTypo @@ -51,7 +51,7 @@ public void UpperCaseIdentityThrows() Action action = () => new Identität1("Identität1-00000000-0000-0000-0000-000000000000"); // Assert - action.Should().Throw(); + action.ShouldThrow(); } [Test] @@ -61,7 +61,7 @@ public void LowerCaseIdentityWorks() var id = new Identität1("identität1-00000000-0000-0000-0000-000000000000"); // Assert - id.GetGuid().Should().BeEmpty(); + id.GetGuid().ShouldBe(Guid.Empty); } [Test] @@ -71,7 +71,7 @@ public void UnicodeIdentities() var identität = Identität1.New.Value; // Assert - identität.Should().StartWith("identität1-"); + identität.ShouldStartWith("identität1-"); } [Test] @@ -86,7 +86,7 @@ public void UnicodeCommands() Action action = () => commandDefinitions.Load(typeof(Cömmand)); // Assert - action.Should().NotThrow(); + action.ShouldNotThrow(); } [Test] @@ -102,7 +102,7 @@ public void UnicodeEvents() Action action = () => eventDefinitionService.Load(typeof(Püng1Event)); // Assert - action.Should().NotThrow(); + action.ShouldNotThrow(); } [Test] diff --git a/Source/EventFlow.Tests/LicenseHeaderTests.cs b/Source/EventFlow.Tests/LicenseHeaderTests.cs index 0175c4f4b..b1dc8a7ad 100644 --- a/Source/EventFlow.Tests/LicenseHeaderTests.cs +++ b/Source/EventFlow.Tests/LicenseHeaderTests.cs @@ -27,8 +27,8 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; // ReSharper disable StringLiteralTypo @@ -61,7 +61,7 @@ public async Task EveryFileHasCorrectLicenseHeader() var sourceFiles = await Task.WhenAll(sourceFilesPaths.Select(GetSourceFileAsync)); // Sanity asserts - sourceFiles.Should().HaveCountGreaterThan(700); + sourceFiles.Length.ShouldBeGreaterThan(700); // Missing headers var missingHeaders = sourceFiles @@ -79,8 +79,8 @@ public async Task EveryFileHasCorrectLicenseHeader() validationErrors.ForEach(Console.WriteLine); // Asserts - missingHeaders.Should().BeEmpty(); - validationErrors.Should().BeEmpty(); + missingHeaders.ShouldBeEmpty(); + validationErrors.ShouldBeEmpty(); } private static string PathRelativeTo(string root, string fullPath) diff --git a/Source/EventFlow.Tests/ReadMeExamples.cs b/Source/EventFlow.Tests/ReadMeExamples.cs index 3e9101593..4159a145a 100644 --- a/Source/EventFlow.Tests/ReadMeExamples.cs +++ b/Source/EventFlow.Tests/ReadMeExamples.cs @@ -29,9 +29,9 @@ using EventFlow.Extensions; using EventFlow.Queries; using EventFlow.ReadStores; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests { @@ -69,7 +69,7 @@ await commandBus.PublishAsync( new ReadModelByIdQuery(exampleId), CancellationToken.None); // Verify that the read model has the expected magic number - exampleReadModel.MagicNumber.Should().Be(42); + exampleReadModel.MagicNumber.ShouldBe(42); } } diff --git a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateFactoryTests.cs b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateFactoryTests.cs index 370b6a9dd..77fdf18ae 100644 --- a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateFactoryTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateFactoryTests.cs @@ -25,9 +25,9 @@ using EventFlow.Aggregates; using EventFlow.Core; using EventFlow.TestHelpers; -using FluentAssertions; using Moq; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Aggregates { @@ -52,8 +52,8 @@ public async Task CanCreateIdOnlyAggregateRootAsync() var idOnlyAggregateRoot = await Sut.CreateNewAggregateAsync(aggregateId).ConfigureAwait(false); // Assert - idOnlyAggregateRoot.Should().NotBeNull(); - idOnlyAggregateRoot.Id.Should().Be(aggregateId); + idOnlyAggregateRoot.ShouldNotBeNull(); + idOnlyAggregateRoot.Id.ShouldBe(aggregateId); } [Test] @@ -68,9 +68,9 @@ public async Task CanCreateAggregateWithServices() var aggregateWithServices = await Sut.CreateNewAggregateAsync(aggregateId).ConfigureAwait(false); // Assert - aggregateWithServices.Should().NotBeNull(); - aggregateWithServices.Id.Should().Be(aggregateId); - aggregateWithServices.Service.Should().BeSameAs(serviceMock.Object); + aggregateWithServices.ShouldNotBeNull(); + aggregateWithServices.Id.ShouldBe(aggregateId); + aggregateWithServices.Service.ShouldBeSameAs(serviceMock.Object); } diff --git a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateIdTests.cs b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateIdTests.cs index 6bd395ed1..1902bbee7 100644 --- a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateIdTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateIdTests.cs @@ -22,8 +22,8 @@ using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Aggregates { @@ -40,7 +40,7 @@ public void ManuallyCreatedIsOk() var testId = ThingyId.With(value); // Test - testId.Value.Should().Be(value); + testId.Value.ShouldBe(value); } [Test] @@ -51,7 +51,7 @@ public void CreatedIsDifferent() var id2 = ThingyId.New; // Assert - id1.Value.Should().NotBe(id2.Value); + id1.Value.ShouldNotBe(id2.Value); } [Test] @@ -63,8 +63,8 @@ public void SameIdsAreEqual() var id2 = ThingyId.With(value); // Assert - id1.Equals(id2).Should().BeTrue(); - (id1 == id2).Should().BeTrue(); + id1.Equals(id2).ShouldBeTrue(); + (id1 == id2).ShouldBeTrue(); } [Test] @@ -75,8 +75,8 @@ public void DifferentAreNotEqual() var id2 = ThingyId.With("thingy-d15b1562-11f2-4645-8b1a-f8b946b566d3"); // Assert - id1.Equals(id2).Should().BeFalse(); - (id1 == id2).Should().BeFalse(); + id1.Equals(id2).ShouldBeFalse(); + (id1 == id2).ShouldBeFalse(); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootApplyEventTests.cs b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootApplyEventTests.cs index 2505551bc..214f8b673 100644 --- a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootApplyEventTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootApplyEventTests.cs @@ -23,8 +23,8 @@ using EventFlow.Aggregates; using EventFlow.Core; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Aggregates { @@ -41,7 +41,7 @@ public void EventApplier() myAggregate.Count(42); // Assert - myAggregate.State.Count.Should().Be(42); + myAggregate.State.Count.ShouldBe(42); } diff --git a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootNameTests.cs b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootNameTests.cs index 73f6861ee..1bb90e212 100644 --- a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootNameTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootNameTests.cs @@ -24,8 +24,8 @@ using EventFlow.Aggregates; using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Aggregates { @@ -57,7 +57,7 @@ public void AggregateName(Type aggregateType, string expectedName) var aggregate = (IAggregateRoot) Activator.CreateInstance(aggregateType, ThingyId.New); // Assert - aggregate.Name.Value.Should().Be(expectedName); + aggregate.Name.Value.ShouldBe(expectedName); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootTests.cs b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootTests.cs index 7786637c2..eac930c40 100644 --- a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateRootTests.cs @@ -27,8 +27,8 @@ using EventFlow.TestHelpers.Aggregates; using EventFlow.TestHelpers.Aggregates.Events; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Aggregates { @@ -40,9 +40,9 @@ public class AggregateRootTests : TestsFor public void InitialVersionIsZero() { // Assert - Sut.Version.Should().Be(0); - Sut.IsNew.Should().BeTrue(); - Sut.UncommittedEvents.Count().Should().Be(0); + Sut.Version.ShouldBe(0); + Sut.IsNew.ShouldBeTrue(); + Sut.UncommittedEvents.Count().ShouldBe(0); } [Test] @@ -52,10 +52,10 @@ public void ApplyingEventIncrementsVersion() Sut.Ping(PingId.New); // Assert - Sut.Version.Should().Be(1); - Sut.IsNew.Should().BeFalse(); - Sut.UncommittedEvents.Count().Should().Be(1); - Sut.PingsReceived.Count.Should().Be(1); + Sut.Version.ShouldBe(1); + Sut.IsNew.ShouldBeFalse(); + Sut.UncommittedEvents.Count().ShouldBe(1); + Sut.PingsReceived.Count.ShouldBe(1); } [Test] @@ -73,10 +73,10 @@ public void EventsCanBeApplied() Sut.ApplyEvents(domainEvents); // Assert - Sut.IsNew.Should().BeFalse(); - Sut.Version.Should().Be(2); - Sut.PingsReceived.Count.Should().Be(2); - Sut.UncommittedEvents.Count().Should().Be(0); + Sut.IsNew.ShouldBeFalse(); + Sut.Version.ShouldBe(2); + Sut.PingsReceived.Count.ShouldBe(2); + Sut.UncommittedEvents.Count().ShouldBe(0); } [Test] @@ -86,7 +86,7 @@ public void EmptyListCanBeApplied() Sut.ApplyEvents(new IDomainEvent[]{}); // Assert - Sut.Version.Should().Be(0); + Sut.Version.ShouldBe(0); } [Test] @@ -96,7 +96,7 @@ public void ApplyIsInvoked() Sut.DomainErrorAfterFirst(); // Assert - Sut.DomainErrorAfterFirstReceived.Should().BeTrue(); + Sut.DomainErrorAfterFirstReceived.ShouldBeTrue(); } [Test] @@ -106,7 +106,7 @@ public void ApplyIsInvokedForExplicitImplementations() Sut.Delete(); // Assert - Sut.IsDeleted.Should().BeTrue(); + Sut.IsDeleted.ShouldBeTrue(); } [Test] @@ -119,7 +119,8 @@ public void UncommittedEventIdsShouldBeDistinct() // Assert Sut.UncommittedEvents .Select(e => e.Metadata.EventId).Distinct() - .Should().HaveCount(2); + .Count() + .ShouldBe(2); } [Test] @@ -139,12 +140,10 @@ public void UncommittedEventIdsShouldBeDeterministic() // GuidFactories.Deterministic.Namespaces.Events, $"{thingyId.Value}-v1" eventIdGuids[0] - .Should() - .Be("event-3dde5ccb-b594-59b4-ad0a-4d432ffce026"); + .ShouldBe("event-3dde5ccb-b594-59b4-ad0a-4d432ffce026"); // GuidFactories.Deterministic.Namespaces.Events, $"{thingyId.Value}-v2" eventIdGuids[1] - .Should() - .Be("event-2e79868f-6ef7-5c88-a941-12ae7ae801c7"); + .ShouldBe("event-2e79868f-6ef7-5c88-a941-12ae7ae801c7"); } [Test] @@ -158,7 +157,7 @@ public void ApplyEventWithOutOfOrderSequenceNumberShouldThrow() Action applyingEvents = () => Sut.ApplyEvents(new []{ domainEvent }); // Assert - applyingEvents.Should().Throw(); + applyingEvents.ShouldThrow(); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateStateTests.cs b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateStateTests.cs index 6c96afbc2..591f0bd86 100644 --- a/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateStateTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Aggregates/AggregateStateTests.cs @@ -26,8 +26,8 @@ using EventFlow.TestHelpers.Aggregates; using EventFlow.TestHelpers.Aggregates.Events; using EventFlow.TestHelpers.Aggregates.ValueObjects; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Aggregates { @@ -44,7 +44,7 @@ public void ApplyIsInvoked() Sut.Apply(null, new ThingyPingEvent(pingId)); // Assert - Sut.PingIds.Should().Contain(pingId); + Sut.PingIds.ShouldContain(pingId); } public class TestAggregateState : AggregateState, diff --git a/Source/EventFlow.Tests/UnitTests/Aggregates/MetadataTests.cs b/Source/EventFlow.Tests/UnitTests/Aggregates/MetadataTests.cs index ed74f4eaf..5166353a6 100644 --- a/Source/EventFlow.Tests/UnitTests/Aggregates/MetadataTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Aggregates/MetadataTests.cs @@ -24,9 +24,9 @@ using System.Collections.Generic; using EventFlow.Aggregates; using EventFlow.TestHelpers; -using FluentAssertions; using Newtonsoft.Json; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Aggregates { @@ -46,7 +46,7 @@ public void TimestampIsSerializedCorrectly() }; // Assert - sut.Timestamp.Should().Be(timestamp); + sut.Timestamp.ShouldBe(timestamp); } [Test] @@ -62,7 +62,7 @@ public void EventNameIsSerializedCorrectly() }; // Assert - sut.EventName.Should().Be(eventName); + sut.EventName.ShouldBe(eventName); } [Test] @@ -78,7 +78,7 @@ public void EventVersionIsSerializedCorrectly() }; // Assert - sut.EventVersion.Should().Be(eventVersion); + sut.EventVersion.ShouldBe(eventVersion); } [Test] @@ -94,7 +94,7 @@ public void AggregateSequenceNumberIsSerializedCorrectly() }; // Assert - sut.AggregateSequenceNumber.Should().Be(aggregateSequenceNumber); + sut.AggregateSequenceNumber.ShouldBe(aggregateSequenceNumber); } [Test] @@ -111,12 +111,12 @@ public void CloneWithCanMerge() var metadata2 = metadata1.CloneWith(new KeyValuePair(key2, value2)); // Assert - metadata1.ContainsKey(key2).Should().BeFalse(); + metadata1.ContainsKey(key2).ShouldBeFalse(); - metadata2.ContainsKey(key1).Should().BeTrue(); - metadata2.ContainsKey(key2).Should().BeTrue(); - metadata2[key1].Should().Be(value1); - metadata2[key2].Should().Be(value2); + metadata2.ContainsKey(key1).ShouldBeTrue(); + metadata2.ContainsKey(key2).ShouldBeTrue(); + metadata2[key1].ShouldBe(value1); + metadata2[key2].ShouldBe(value2); } [Test] @@ -138,10 +138,10 @@ public void SerializeDeserializeWithValues() var metadata = JsonConvert.DeserializeObject(json); // Assert - metadata.Count.Should().Be(3); - metadata.AggregateName.Should().Be(aggregateName); - metadata.AggregateSequenceNumber.Should().Be(aggregateSequenceNumber); - metadata.Timestamp.Should().Be(timestamp); + metadata.Count.ShouldBe(3); + metadata.AggregateName.ShouldBe(aggregateName); + metadata.AggregateSequenceNumber.ShouldBe(aggregateSequenceNumber); + metadata.Timestamp.ShouldBe(timestamp); } [Test] @@ -155,8 +155,8 @@ public void SerializeDeserializeEmpty() var metadata = JsonConvert.DeserializeObject(json); // Assert - json.Should().Be("{}"); - metadata.Count.Should().Be(0); + json.ShouldBe("{}"); + metadata.Count.ShouldBe(0); } } } diff --git a/Source/EventFlow.Tests/UnitTests/Commands/CommandTests.cs b/Source/EventFlow.Tests/UnitTests/Commands/CommandTests.cs index 3d23150a8..e93498877 100644 --- a/Source/EventFlow.Tests/UnitTests/Commands/CommandTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Commands/CommandTests.cs @@ -25,9 +25,9 @@ using EventFlow.Commands; using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; -using FluentAssertions; using Newtonsoft.Json; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Commands { @@ -55,9 +55,9 @@ public void SerializeDeserialize() var deserialized = JsonConvert.DeserializeObject(json); // Assert - deserialized.CriticalData.Should().Be(criticalCommand.CriticalData); - deserialized.SourceId.Should().Be(criticalCommand.SourceId); - deserialized.AggregateId.Should().Be(criticalCommand.AggregateId); + deserialized.CriticalData.ShouldBe(criticalCommand.CriticalData); + deserialized.SourceId.ShouldBe(criticalCommand.SourceId); + deserialized.AggregateId.ShouldBe(criticalCommand.AggregateId); } } } diff --git a/Source/EventFlow.Tests/UnitTests/Commands/DistinctCommandTests.cs b/Source/EventFlow.Tests/UnitTests/Commands/DistinctCommandTests.cs index 052b73513..879f90584 100644 --- a/Source/EventFlow.Tests/UnitTests/Commands/DistinctCommandTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Commands/DistinctCommandTests.cs @@ -27,8 +27,8 @@ using EventFlow.Extensions; using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Commands { @@ -66,7 +66,7 @@ public void Arguments(string aggregateId, int magicNumber, string expectedSouceI var sourceId = command.SourceId; // Assert - sourceId.Value.Should().Be(expectedSouceId); + sourceId.Value.ShouldBe(expectedSouceId); } } } diff --git a/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndClassNameStrategyTest.cs b/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndClassNameStrategyTest.cs index 52119fb32..49ba644b7 100644 --- a/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndClassNameStrategyTest.cs +++ b/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndClassNameStrategyTest.cs @@ -22,8 +22,8 @@ using EventFlow.Configuration.EventNamingStrategy; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Configuration.EventNamingStrategy { @@ -42,7 +42,7 @@ public void EventNameShouldBeNamespaceAndClassName() var name = strategy.CreateEventName(1, typeof(Any), "OriginalName"); // Assert - name.Should().Be(GetType().Namespace + ".Any"); + name.ShouldBe(GetType().Namespace + ".Any"); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndNameStrategyTest.cs b/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndNameStrategyTest.cs index b144cb51c..8bcb5b3ab 100644 --- a/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndNameStrategyTest.cs +++ b/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/NamespaceAndNameStrategyTest.cs @@ -21,9 +21,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using EventFlow.Configuration.EventNamingStrategy; -using EventFlow.EventStores; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Configuration.EventNamingStrategy { @@ -41,7 +40,7 @@ public void EventNameShouldBeNamespaceAndClassName() var name = strategy.CreateEventName(1, typeof(Any), "NameFromAttribute"); // Assert - name.Should().Be(GetType().Namespace + ".NameFromAttribute"); + name.ShouldBe(GetType().Namespace + ".NameFromAttribute"); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/VoidStrategyTest.cs b/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/VoidStrategyTest.cs index 3fee98f5a..2a74e678e 100644 --- a/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/VoidStrategyTest.cs +++ b/Source/EventFlow.Tests/UnitTests/Configuration/EventNamingStrategy/VoidStrategyTest.cs @@ -22,8 +22,8 @@ using EventFlow.Configuration.EventNamingStrategy; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Configuration.EventNamingStrategy { @@ -42,7 +42,7 @@ public void EventNameShouldBeUnchanged() var name = strategy.CreateEventName(1, typeof(Any), "OriginalName"); // Assert - name.Should().Be("OriginalName"); + name.ShouldBe("OriginalName"); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Configuration/Serialization/JsonOptionsTests.cs b/Source/EventFlow.Tests/UnitTests/Configuration/Serialization/JsonOptionsTests.cs index acf6948fa..38d447024 100644 --- a/Source/EventFlow.Tests/UnitTests/Configuration/Serialization/JsonOptionsTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Configuration/Serialization/JsonOptionsTests.cs @@ -24,10 +24,10 @@ using EventFlow.Extensions; using EventFlow.TestHelpers; using EventFlow.ValueObjects; -using FluentAssertions; using Newtonsoft.Json; using NUnit.Framework; using System; +using Shouldly; namespace EventFlow.Tests.UnitTests.Configuration.Serialization { @@ -77,11 +77,11 @@ public void JsonOptionsCanBeUsedToConstructJsonSerializerSettings() var svoDeserialized = JsonConvert.DeserializeObject(svoSerialized); // Assert - myClassSerialized.Should().Be("1000000"); - myClassDeserialized.DateTime.Ticks.Should().Be(1000000); - myClassDeserialized.DateTime.Ticks.Should().NotBe(10); - svoDeserialized.Should().Be(new MySingleValueObject(new DateTime(1970, 1, 1))); - svoDeserialized.Should().NotBe(new MySingleValueObject(new DateTime(2001, 1, 1))); + myClassSerialized.ShouldBe("1000000"); + myClassDeserialized.DateTime.Ticks.ShouldBe(1000000); + myClassDeserialized.DateTime.Ticks.ShouldNotBe(10); + svoDeserialized.ShouldBe(new MySingleValueObject(new DateTime(1970, 1, 1))); + svoDeserialized.ShouldNotBe(new MySingleValueObject(new DateTime(2001, 1, 1))); } } } diff --git a/Source/EventFlow.Tests/UnitTests/Core/CircularBufferTests.cs b/Source/EventFlow.Tests/UnitTests/Core/CircularBufferTests.cs index 3c318c2b6..6527d1384 100644 --- a/Source/EventFlow.Tests/UnitTests/Core/CircularBufferTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Core/CircularBufferTests.cs @@ -23,8 +23,8 @@ using System.Linq; using EventFlow.Core; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Core { @@ -50,7 +50,11 @@ public void Put(params int[] numbers) // Assert var shouldContain = numbers.Reverse().Take(capacity).ToList(); - sut.Should().Contain(shouldContain); + + foreach (var sc in shouldContain) + { + sut.ShouldContain(sc); + } } [Test] @@ -67,7 +71,7 @@ public void OrderAboveCapacity() var numbers = sut.ToArray(); // Assert - numbers.Should().ContainInOrder(2, 3, 4); + numbers.ShouldBe(new[] {2, 3, 4}, ignoreOrder: false); } [Test] @@ -83,7 +87,7 @@ public void OrderAtCapacity() var numbers = sut.ToArray(); // Assert - numbers.Should().ContainInOrder(1, 2, 3); + numbers.ShouldBe( new[] {1, 2, 3}, ignoreOrder: false); } [Test] @@ -98,7 +102,7 @@ public void OrderBelowCapacity() var numbers = sut.ToArray(); // Assert - numbers.Should().ContainInOrder(1, 2); + numbers.ShouldBe(new[] {1, 2}, ignoreOrder: false); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Core/GuidFactories/GuidFactoriesDeterministicTests.cs b/Source/EventFlow.Tests/UnitTests/Core/GuidFactories/GuidFactoriesDeterministicTests.cs index 95958286a..caef88f7b 100644 --- a/Source/EventFlow.Tests/UnitTests/Core/GuidFactories/GuidFactoriesDeterministicTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Core/GuidFactories/GuidFactoriesDeterministicTests.cs @@ -25,8 +25,8 @@ using System.Linq; using AutoFixture; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Core.GuidFactories { @@ -52,7 +52,7 @@ public void Create_EmptyNameBytes_ThrowsArgumentNullException() public void Create(Guid namespaceId, byte[] nameBytes, Guid expected) { var result = EventFlow.Core.GuidFactories.Deterministic.Create(namespaceId, nameBytes); - result.Should().Be(expected); + result.ShouldBe(expected); } private static IEnumerable GetTestCases() diff --git a/Source/EventFlow.Tests/UnitTests/Core/IdentityTests.cs b/Source/EventFlow.Tests/UnitTests/Core/IdentityTests.cs index b32ec053f..ee8c02fc8 100644 --- a/Source/EventFlow.Tests/UnitTests/Core/IdentityTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Core/IdentityTests.cs @@ -24,7 +24,7 @@ using EventFlow.Core; using EventFlow.TestHelpers; using EventFlow.TestHelpers.Aggregates; -using FluentAssertions; +using Shouldly; using NUnit.Framework; namespace EventFlow.Tests.UnitTests.Core @@ -43,8 +43,8 @@ public void NewDeterministic_ReturnsKnownResult() var testId = ThingyId.NewDeterministic(namespaceId, name); // Assert - testId.Value.Should().Be("thingy-da7ab6b1-c513-581f-a1a0-7cdf17109deb"); - ThingyId.IsValid(testId.Value).Should().BeTrue(); + testId.Value.ShouldBe("thingy-da7ab6b1-c513-581f-a1a0-7cdf17109deb"); + ThingyId.IsValid(testId.Value).ShouldBeTrue(); } [TestCase("thingy-da7ab6b1-c513-581f-a1a0-7cdf17109deb", "da7ab6b1-c513-581f-a1a0-7cdf17109deb")] @@ -59,9 +59,9 @@ public void WithValidValue(string value, string expectedGuidValue) Assert.DoesNotThrow(() => thingyId = ThingyId.With(value)); // Assert - thingyId.Should().NotBeNull(); - thingyId.Value.Should().Be(value); - thingyId.GetGuid().Should().Be(expectedGuid); + thingyId.ShouldNotBeNull(); + thingyId.Value.ShouldBe(value); + thingyId.GetGuid().ShouldBe(expectedGuid); } [Test] @@ -74,7 +74,7 @@ public void InputOutput() var thingyId = ThingyId.With(guid); // Assert - thingyId.GetGuid().Should().Be(guid); + thingyId.GetGuid().ShouldBe(guid); } [Test] @@ -84,7 +84,7 @@ public void ShouldBeLowerCase() var testId = ThingyId.New; // Assert - testId.Value.Should().Be(testId.Value.ToLowerInvariant()); + testId.Value.ShouldBe(testId.Value.ToLowerInvariant()); } [Test] @@ -94,7 +94,7 @@ public void New_IsValid() var testId = ThingyId.New; // Assert - ThingyId.IsValid(testId.Value).Should().BeTrue(testId.Value); + ThingyId.IsValid(testId.Value).ShouldBeTrue(testId.Value); } [Test] @@ -104,7 +104,7 @@ public void NewComb_IsValid() var testId = ThingyId.NewComb(); // Assert - ThingyId.IsValid(testId.Value).Should().BeTrue(testId.Value); + ThingyId.IsValid(testId.Value).ShouldBeTrue(testId.Value); } [Test] @@ -114,7 +114,7 @@ public void NewDeterministic_IsValid() var testId = ThingyId.NewDeterministic(Guid.NewGuid(), Guid.NewGuid().ToString()); // Assert - ThingyId.IsValid(testId.Value).Should().BeTrue(testId.Value); + ThingyId.IsValid(testId.Value).ShouldBeTrue(testId.Value); } [TestCase("da7ab6b1-c513-581f-a1a0-7cdf17109deb")] @@ -127,7 +127,8 @@ public void NewDeterministic_IsValid() public void CannotCreateBadIds(string badIdValue) { // Act - Assert.Throws(() => ThingyId.With(badIdValue)).Message.Should().Contain("Identity is invalid:"); + var exception = Assert.Throws(() => ThingyId.With(badIdValue)); + exception.Message.ShouldContain("Identity is invalid:"); } public class Id : Identity @@ -148,7 +149,7 @@ public void JustId() var id = Id.With(guid); // Assert - id.Value.Should().Be(expected); + id.Value.ShouldBe(expected); } } } diff --git a/Source/EventFlow.Tests/UnitTests/Core/ReflectionHelperTests.cs b/Source/EventFlow.Tests/UnitTests/Core/ReflectionHelperTests.cs index c9de8a0d0..153300696 100644 --- a/Source/EventFlow.Tests/UnitTests/Core/ReflectionHelperTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Core/ReflectionHelperTests.cs @@ -23,8 +23,8 @@ using System; using EventFlow.Core; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Core { @@ -39,7 +39,7 @@ public void CompileMethodInvocation() var result = caller(new Calculator(), 1, 2); // Assert - result.Should().Be(3); + result.ShouldBe(3); } [Test] @@ -55,7 +55,7 @@ public void CompileMethodInvocation_CanUpcast() // Assert var c = (Number) result; - c.I.Should().Be(3); + c.I.ShouldBe(3); } [Test] @@ -71,7 +71,7 @@ public void CompileMethodInvocation_CanDoBothUpcastAndPass() // Assert var c = (Number)result; - c.I.Should().Be(3); + c.I.ShouldBe(3); } public interface INumber { } diff --git a/Source/EventFlow.Tests/UnitTests/Core/RetryDelayTests.cs b/Source/EventFlow.Tests/UnitTests/Core/RetryDelayTests.cs index 86d6a9950..b5163a549 100644 --- a/Source/EventFlow.Tests/UnitTests/Core/RetryDelayTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Core/RetryDelayTests.cs @@ -23,8 +23,8 @@ using System; using EventFlow.Core; using EventFlow.TestHelpers; -using FluentAssertions; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Core { @@ -46,8 +46,8 @@ public void PickDelay_IsWithinBounds() var delay = sut.PickDelay(); // Assert - delay.TotalMilliseconds.Should().BeGreaterOrEqualTo(min); - delay.TotalMilliseconds.Should().BeLessOrEqualTo(max); + delay.TotalMilliseconds.ShouldBeGreaterThanOrEqualTo(min); + delay.TotalMilliseconds.ShouldBeLessThanOrEqualTo(max); } } } \ No newline at end of file diff --git a/Source/EventFlow.Tests/UnitTests/Core/RetryStrategies/OptimisticConcurrencyRetryStrategyTests.cs b/Source/EventFlow.Tests/UnitTests/Core/RetryStrategies/OptimisticConcurrencyRetryStrategyTests.cs index f9694d334..895957c03 100644 --- a/Source/EventFlow.Tests/UnitTests/Core/RetryStrategies/OptimisticConcurrencyRetryStrategyTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Core/RetryStrategies/OptimisticConcurrencyRetryStrategyTests.cs @@ -25,9 +25,9 @@ using EventFlow.Core.RetryStrategies; using EventFlow.Exceptions; using EventFlow.TestHelpers; -using FluentAssertions; using Moq; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Core.RetryStrategies { @@ -63,7 +63,7 @@ public void ShouldThisBeRetried_OptimisticConcurrencyException_ShouldBeRetired(i var shouldThisBeRetried = Sut.ShouldThisBeRetried(optimisticConcurrencyException, A(), currentRetryCount); // Assert - shouldThisBeRetried.ShouldBeRetried.Should().Be(expectedShouldThisBeRetried); + shouldThisBeRetried.ShouldBeRetried.ShouldBe(expectedShouldThisBeRetried); } [TestCase(0)] @@ -80,7 +80,7 @@ public void ShouldThisBeRetried_Exception_ShouldNeverBeRetired(int currentRetryC var shouldThisBeRetried = Sut.ShouldThisBeRetried(exception, A(), currentRetryCount); // Assert - shouldThisBeRetried.ShouldBeRetried.Should().BeFalse(); + shouldThisBeRetried.ShouldBeRetried.ShouldBeFalse(); } } diff --git a/Source/EventFlow.Tests/UnitTests/Core/TransientFaultHandlerTests.cs b/Source/EventFlow.Tests/UnitTests/Core/TransientFaultHandlerTests.cs index 8fd22e814..0ba677595 100644 --- a/Source/EventFlow.Tests/UnitTests/Core/TransientFaultHandlerTests.cs +++ b/Source/EventFlow.Tests/UnitTests/Core/TransientFaultHandlerTests.cs @@ -25,10 +25,10 @@ using System.Threading.Tasks; using EventFlow.Core; using EventFlow.TestHelpers; -using FluentAssertions; using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; +using Shouldly; namespace EventFlow.Tests.UnitTests.Core { @@ -73,14 +73,14 @@ public async Task Result() var result = await Sut.TryAsync(c => action.Object(), A