diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj index ea796b02..38bdd63e 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests.csproj @@ -17,7 +17,8 @@ - + + diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_api.cs b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_api.cs index afbe2587..198b3222 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_api.cs +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_api.cs @@ -25,7 +25,7 @@ public async Task Should_be_used() .Done(c => c.SagaReceivedMessage) .Run(runSettings); - Assert.True(context.ExtractorWasCalled); + Assert.That(context.ExtractorWasCalled, Is.True); } public class Context : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_di.cs b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_di.cs index 5d4b4979..7e2457b3 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_di.cs +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_message_registered_via_di.cs @@ -26,7 +26,7 @@ public async Task Should_be_used() .Done(c => c.SagaReceivedMessage) .Run(runSettings); - Assert.True(context.ExtractorWasCalled); + Assert.That(context.ExtractorWasCalled, Is.True); } public class Context : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_api.cs b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_api.cs index 54f31fcf..cdb89b47 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_api.cs +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_api.cs @@ -26,7 +26,7 @@ public async Task Should_be_used() .Done(c => c.SagaReceivedMessage) .Run(runSettings); - Assert.True(context.ExtractorWasCalled); + Assert.That(context.ExtractorWasCalled, Is.True); } public class Context : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_di.cs b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_di.cs index 3fe9afe8..9e143073 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_di.cs +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_custom_partition_key_extractor_from_message_registered_via_di.cs @@ -27,7 +27,7 @@ public async Task Should_be_used() .Done(c => c.SagaReceivedMessage) .Run(runSettings); - Assert.True(context.ExtractorWasCalled); + Assert.That(context.ExtractorWasCalled, Is.True); } public class Context : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_fluent_extractor_registered_via_api.cs b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_fluent_extractor_registered_via_api.cs index 9a96cd8e..e25e22e9 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_fluent_extractor_registered_via_api.cs +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_fluent_extractor_registered_via_api.cs @@ -23,8 +23,11 @@ public async Task Should_work() .Done(c => c.SagaReceivedMessage) .Run(runSettings); - Assert.True(context.PartitionStateMatched); - Assert.True(context.ContainerStateMatched); + Assert.Multiple(() => + { + Assert.That(context.PartitionStateMatched, Is.True); + Assert.That(context.ContainerStateMatched, Is.True); + }); } public class Context : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs index 8e2b8ae4..42338c0a 100644 --- a/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs +++ b/src/NServiceBus.Persistence.CosmosDB.LogicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs @@ -8,8 +8,11 @@ public partial class When_using_outbox_synchronized_session_via_container partial void AssertPartitionPart(Context scenarioContext) { string partitionKeyPath = scenarioContext.PartitionKeyPath; - Assert.AreEqual(SetupFixture.PartitionPathKey, partitionKeyPath); - Assert.AreEqual(new PartitionKey(scenarioContext.TestRunId.ToString()), scenarioContext.PartitionKey); + Assert.Multiple(() => + { + Assert.That(partitionKeyPath, Is.EqualTo(SetupFixture.PartitionPathKey)); + Assert.That(scenarioContext.PartitionKey, Is.EqualTo(new PartitionKey(scenarioContext.TestRunId.ToString()))); + }); } } } \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj index ee269c02..bc17c7ec 100644 --- a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests.csproj @@ -17,7 +17,8 @@ - + + diff --git a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_custom_container_is_overwritten.cs b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_custom_container_is_overwritten.cs index aea446c1..2f2b5827 100644 --- a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_custom_container_is_overwritten.cs +++ b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_custom_container_is_overwritten.cs @@ -58,8 +58,11 @@ public async Task Should_persist_into_the_provided_container() var shippingProcessSagaData = await nonDefaultContainer.ReadItemAsync(context.ShippingProcessId, new PartitionKey(context.ShippingProcessId)); - Assert.AreEqual(HttpStatusCode.OK, orderProcessSagaData.StatusCode); - Assert.AreEqual(HttpStatusCode.OK, shippingProcessSagaData.StatusCode); + Assert.Multiple(() => + { + Assert.That(orderProcessSagaData.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + Assert.That(shippingProcessSagaData.StatusCode, Is.EqualTo(HttpStatusCode.OK)); + }); } [TearDown] diff --git a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_handling_migrated_saga.cs b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_handling_migrated_saga.cs index b6f89e7a..e0ab0aa6 100644 --- a/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_handling_migrated_saga.cs +++ b/src/NServiceBus.Persistence.CosmosDB.NonTransactionalSagas.AcceptanceTests/When_handling_migrated_saga.cs @@ -54,7 +54,7 @@ static async Task ImportIntoCosmosDB(Context scenarioContext) { var response = await container.CreateItemStreamAsync(stream, new PartitionKey(actualSagaId.ToString())); - Assert.IsTrue(response.IsSuccessStatusCode, "Successfully imported"); + Assert.That(response.IsSuccessStatusCode, Is.True, "Successfully imported"); } } diff --git a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj index 3f45af25..683871e1 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/NServiceBus.Persistence.CosmosDB.PersistenceTests.csproj @@ -17,6 +17,7 @@ + diff --git a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/SetupFixture.cs b/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/SetupFixture.cs index 0e3e5db0..7f234cfa 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/SetupFixture.cs +++ b/src/NServiceBus.Persistence.CosmosDB.PersistenceTests/SetupFixture.cs @@ -45,9 +45,10 @@ public async Task OneTimeSetUp() } [OneTimeTearDown] - public Task OneTimeTearDown() + public async Task OneTimeTearDown() { - return Container.DeleteContainerStreamAsync(); + await Container.DeleteContainerStreamAsync(); + CosmosDbClient.Dispose(); } static string GetEnvironmentVariable(string variable, string fallbackEmulatorConnectionString) diff --git a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj index 9ea7c299..5c1270bd 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests.csproj @@ -17,7 +17,8 @@ - + + diff --git a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_migrated_saga_with_high_contention.cs b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_migrated_saga_with_high_contention.cs index e1657437..e2d7e523 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_migrated_saga_with_high_contention.cs +++ b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_migrated_saga_with_high_contention.cs @@ -38,8 +38,11 @@ await Task.WhenAll(Enumerable.Range(0, scenarioContext.ConcurrentMessageCount).S .Done(s => s.SagaCompleted) .Run(); - Assert.IsTrue(context.ConcurrentMessagesSent); - Assert.AreEqual(0, context.RetryCount); + Assert.Multiple(() => + { + Assert.That(context.ConcurrentMessagesSent, Is.True); + Assert.That(context.RetryCount, Is.EqualTo(0)); + }); } static string MigrationDocument = @"{{ @@ -67,7 +70,7 @@ static async Task ImportIntoCosmosDB(HighContentionScenario scenarioContext) { var response = await container.CreateItemStreamAsync(stream, new PartitionKey(actualSagaId.ToString())); - Assert.IsTrue(response.IsSuccessStatusCode, "Successfully imported"); + Assert.That(response.IsSuccessStatusCode, Is.True, "Successfully imported"); } } diff --git a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_saga_with_high_contention.cs b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_saga_with_high_contention.cs index 17cc9744..39429009 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_saga_with_high_contention.cs +++ b/src/NServiceBus.Persistence.CosmosDB.PessimisticLock.AcceptanceTests/When_storing_saga_with_high_contention.cs @@ -22,8 +22,11 @@ public async Task Should_succeed_without_retries() .Done(s => s.SagaCompleted) .Run(); - Assert.IsTrue(scenario.ConcurrentMessagesSent); - Assert.AreEqual(0, scenario.RetryCount); + Assert.Multiple(() => + { + Assert.That(scenario.ConcurrentMessagesSent, Is.True); + Assert.That(scenario.RetryCount, Is.EqualTo(0)); + }); } public class HighContentionScenario : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj index ea796b02..38bdd63e 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests.csproj @@ -17,7 +17,8 @@ - + + diff --git a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_api.cs b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_api.cs index 7880032a..43b61bb0 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_api.cs +++ b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_api.cs @@ -25,7 +25,7 @@ public async Task Should_be_used() .Done(c => c.SagaReceivedMessage) .Run(runSettings); - Assert.True(context.ExtractorWasCalled); + Assert.That(context.ExtractorWasCalled, Is.True); } public class Context : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_di.cs b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_di.cs index d61db4b7..b9faad9b 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_di.cs +++ b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_custom_container_information_extractor_from_headers_registered_via_di.cs @@ -26,7 +26,7 @@ public async Task Should_be_used() .Done(c => c.SagaReceivedMessage) .Run(runSettings); - Assert.True(context.ExtractorWasCalled); + Assert.That(context.ExtractorWasCalled, Is.True); } public class Context : ScenarioContext diff --git a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs index 8e2b8ae4..2b9531f2 100644 --- a/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs +++ b/src/NServiceBus.Persistence.CosmosDB.PhysicalOutbox.AcceptanceTests/When_using_outbox_synchronized_session_via_container_partial.cs @@ -8,8 +8,8 @@ public partial class When_using_outbox_synchronized_session_via_container partial void AssertPartitionPart(Context scenarioContext) { string partitionKeyPath = scenarioContext.PartitionKeyPath; - Assert.AreEqual(SetupFixture.PartitionPathKey, partitionKeyPath); - Assert.AreEqual(new PartitionKey(scenarioContext.TestRunId.ToString()), scenarioContext.PartitionKey); + Assert.That(partitionKeyPath, Is.EqualTo(SetupFixture.PartitionPathKey)); + Assert.That(scenarioContext.PartitionKey, Is.EqualTo(new PartitionKey(scenarioContext.TestRunId.ToString()))); } } } \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj b/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj index 0f1d4974..9a85254b 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/NServiceBus.Persistence.CosmosDB.Tests.csproj @@ -13,7 +13,8 @@ - + + diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs index c3b6466e..3580fd54 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Outbox/LogicalOutboxBehaviorTests.cs @@ -63,8 +63,11 @@ public async Task Should_clear_added_pending_operations_and_restore_ones_from_ou await behavior.Invoke(testableContext, c => Task.CompletedTask); - Assert.IsTrue(pendingTransportOperations.HasOperations, "Should have exactly one operation added found on the outbox record"); - Assert.AreEqual("42", pendingTransportOperations.Operations.ElementAt(0).Message.MessageId, "Should have exactly one operation added found on the outbox record"); + Assert.Multiple(() => + { + Assert.That(pendingTransportOperations.HasOperations, Is.True, "Should have exactly one operation added found on the outbox record"); + Assert.That(pendingTransportOperations.Operations.ElementAt(0).Message.MessageId, Is.EqualTo("42"), "Should have exactly one operation added found on the outbox record"); + }); } } diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/PessimisticLockingConfigurationTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/PessimisticLockingConfigurationTests.cs index c6b04642..60a1a1af 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/PessimisticLockingConfigurationTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/PessimisticLockingConfigurationTests.cs @@ -11,11 +11,14 @@ public void Should_have_default_values() { var configuration = new PessimisticLockingConfiguration(); - Assert.That(configuration.LeaseLockTime, Is.EqualTo(TimeSpan.FromMinutes(1))); - Assert.That(configuration.LeaseLockAcquisitionTimeout, Is.EqualTo(TimeSpan.FromMinutes(1))); - Assert.That(configuration.LeaseLockAcquisitionMinimumRefreshDelay, Is.EqualTo(TimeSpan.FromMilliseconds(500))); - Assert.That(configuration.LeaseLockAcquisitionMaximumRefreshDelay, Is.EqualTo(TimeSpan.FromMilliseconds(1000))); - Assert.That(configuration.PessimisticLockingEnabled, Is.False); + Assert.Multiple(() => + { + Assert.That(configuration.LeaseLockTime, Is.EqualTo(TimeSpan.FromMinutes(1))); + Assert.That(configuration.LeaseLockAcquisitionTimeout, Is.EqualTo(TimeSpan.FromMinutes(1))); + Assert.That(configuration.LeaseLockAcquisitionMinimumRefreshDelay, Is.EqualTo(TimeSpan.FromMilliseconds(500))); + Assert.That(configuration.LeaseLockAcquisitionMaximumRefreshDelay, Is.EqualTo(TimeSpan.FromMilliseconds(1000))); + Assert.That(configuration.PessimisticLockingEnabled, Is.False); + }); } [Test] @@ -35,7 +38,7 @@ public void Should_set_lease_lock_time([Random(1, 10, 5, Distinct = true)] doubl configuration.SetLeaseLockTime(fromMinutes); - Assert.AreEqual(fromMinutes, configuration.LeaseLockTime); + Assert.That(configuration.LeaseLockTime, Is.EqualTo(fromMinutes)); } [Test] @@ -55,7 +58,7 @@ public void Should_set_lease_lock_acquisition_timeout([Random(1, 10, 5, Distinct configuration.SetLeaseLockTime(fromMinutes); - Assert.AreEqual(fromMinutes, configuration.LeaseLockTime); + Assert.That(configuration.LeaseLockTime, Is.EqualTo(fromMinutes)); } [Test] @@ -95,7 +98,7 @@ public void Should_set_minimum_refresh_delay_when_below_default_maximum_refresh_ configuration.SetLeaseLockAcquisitionMinimumRefreshDelay(fromMilliseconds); configuration.ValidateRefreshDelays(); - Assert.AreEqual(fromMilliseconds, configuration.LeaseLockAcquisitionMinimumRefreshDelay); + Assert.That(configuration.LeaseLockAcquisitionMinimumRefreshDelay, Is.EqualTo(fromMilliseconds)); } [Test] @@ -109,7 +112,7 @@ public void Should_set_minimum_refresh_delay_when_below_maximum_refresh_delay([R configuration.SetLeaseLockAcquisitionMinimumRefreshDelay(fromMilliseconds); configuration.ValidateRefreshDelays(); - Assert.AreEqual(fromMilliseconds, configuration.LeaseLockAcquisitionMinimumRefreshDelay); + Assert.That(configuration.LeaseLockAcquisitionMinimumRefreshDelay, Is.EqualTo(fromMilliseconds)); } [Test] @@ -149,7 +152,7 @@ public void Should_set_maximum_refresh_delay_when_above_default_minimum_refresh_ configuration.SetLeaseLockAcquisitionMaximumRefreshDelay(fromMilliseconds); configuration.ValidateRefreshDelays(); - Assert.AreEqual(fromMilliseconds, configuration.LeaseLockAcquisitionMaximumRefreshDelay); + Assert.That(configuration.LeaseLockAcquisitionMaximumRefreshDelay, Is.EqualTo(fromMilliseconds)); } [Test] @@ -163,7 +166,7 @@ public void Should_set_maximum_refresh_delay_when_above_minimum_refresh_delay([R configuration.SetLeaseLockAcquisitionMaximumRefreshDelay(fromMilliseconds); configuration.ValidateRefreshDelays(); - Assert.AreEqual(fromMilliseconds, configuration.LeaseLockAcquisitionMaximumRefreshDelay); + Assert.That(configuration.LeaseLockAcquisitionMaximumRefreshDelay, Is.EqualTo(fromMilliseconds)); } } } \ No newline at end of file diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/SagaIdGeneratorTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/SagaIdGeneratorTests.cs index 17b1def3..042e1232 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/SagaIdGeneratorTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Saga/SagaIdGeneratorTests.cs @@ -12,11 +12,11 @@ public class SagaIdGeneratorTests { [Test] public void Should_return_the_same_guid_regardless_of_the_tfm() => - Assert.AreEqual(new Guid("c718ea15-a555-f79f-fa37-62477f3b07ca"), CosmosSagaIdGenerator.Generate("SagaEntityTypeFullName", "CorrelationPropertyName", "SomeValue")); + Assert.That(CosmosSagaIdGenerator.Generate("SagaEntityTypeFullName", "CorrelationPropertyName", "SomeValue"), Is.EqualTo(new Guid("c718ea15-a555-f79f-fa37-62477f3b07ca"))); - [TestCaseSource("RandomInput")] + [TestCaseSource(nameof(RandomInput))] public void Should_return_the_same_guid_as_previous(string fullname, string propertyName, string propertyValue) => - Assert.AreEqual(PreviousCosmosSagaIdGenerator.Generate(fullname, propertyName, propertyValue), CosmosSagaIdGenerator.Generate(fullname, propertyName, propertyValue)); + Assert.That(CosmosSagaIdGenerator.Generate(fullname, propertyName, propertyValue), Is.EqualTo(PreviousCosmosSagaIdGenerator.Generate(fullname, propertyName, propertyValue))); public static IEnumerable RandomInput { diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/StorageSessionTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/StorageSessionTests.cs index 714e1da9..58b3f4df 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/StorageSessionTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/StorageSessionTests.cs @@ -38,10 +38,13 @@ public async Task Should_not_complete_when_owned_by_outbox_transaction() await storageSession.CompleteAsync(); storageSession.Dispose(); - Assert.That(firstOperation.WasDisposed, Is.False); - Assert.That(firstOperation.WasApplied, Is.False); - Assert.That(secondOperation.WasDisposed, Is.False); - Assert.That(secondOperation.WasApplied, Is.False); + Assert.Multiple(() => + { + Assert.That(firstOperation.WasDisposed, Is.False); + Assert.That(firstOperation.WasApplied, Is.False); + Assert.That(secondOperation.WasDisposed, Is.False); + Assert.That(secondOperation.WasApplied, Is.False); + }); } [Test] @@ -73,15 +76,18 @@ public async Task Should_complete_when_outbox_transaction_completes() await outboxTransaction.Commit(); outboxTransaction.Dispose(); - Assert.That(firstOperationWasDisposed, Is.False); - Assert.That(firstOperationWasApplied, Is.False); - Assert.That(secondOperationWasDisposed, Is.False); - Assert.That(secondOperationWasApplied, Is.False); - - Assert.That(firstOperation.WasDisposed, Is.True); - Assert.That(firstOperation.WasApplied, Is.True); - Assert.That(secondOperation.WasDisposed, Is.True); - Assert.That(secondOperation.WasApplied, Is.True); + Assert.Multiple(() => + { + Assert.That(firstOperationWasDisposed, Is.False); + Assert.That(firstOperationWasApplied, Is.False); + Assert.That(secondOperationWasDisposed, Is.False); + Assert.That(secondOperationWasApplied, Is.False); + + Assert.That(firstOperation.WasDisposed, Is.True); + Assert.That(firstOperation.WasApplied, Is.True); + Assert.That(secondOperation.WasDisposed, Is.True); + Assert.That(secondOperation.WasApplied, Is.True); + }); } [Test] @@ -99,7 +105,7 @@ public async Task Should_set_current_context_bag_to_inner_when_using_outbox_tran var synchronizedStorageSessionContextBag = new ContextBag(); await storageSession.TryOpen(outboxTransaction, synchronizedStorageSessionContextBag); - Assert.AreSame(synchronizedStorageSessionContextBag, storageSession.CurrentContextBag); + Assert.That(storageSession.CurrentContextBag, Is.SameAs(synchronizedStorageSessionContextBag)); } [Test] @@ -150,10 +156,13 @@ public async Task Should_dispose_operations() storageSession.Dispose(); - Assert.That(firstOperation.WasDisposed, Is.True); - Assert.That(firstOperation.WasApplied, Is.False); - Assert.That(secondOperation.WasDisposed, Is.True); - Assert.That(secondOperation.WasApplied, Is.False); + Assert.Multiple(() => + { + Assert.That(firstOperation.WasDisposed, Is.True); + Assert.That(firstOperation.WasApplied, Is.False); + Assert.That(secondOperation.WasDisposed, Is.True); + Assert.That(secondOperation.WasApplied, Is.False); + }); } [Test] @@ -179,15 +188,18 @@ public async Task Should_dispose_operations_when_outbox_transaction_disposes() outboxTransaction.Dispose(); - Assert.That(firstOperationWasDisposed, Is.False); - Assert.That(firstOperationWasApplied, Is.False); - Assert.That(secondOperationWasDisposed, Is.False); - Assert.That(secondOperationWasApplied, Is.False); - - Assert.That(firstOperation.WasDisposed, Is.True); - Assert.That(firstOperation.WasApplied, Is.False); - Assert.That(secondOperation.WasDisposed, Is.True); - Assert.That(secondOperation.WasApplied, Is.False); + Assert.Multiple(() => + { + Assert.That(firstOperationWasDisposed, Is.False); + Assert.That(firstOperationWasApplied, Is.False); + Assert.That(secondOperationWasDisposed, Is.False); + Assert.That(secondOperationWasApplied, Is.False); + + Assert.That(firstOperation.WasDisposed, Is.True); + Assert.That(firstOperation.WasApplied, Is.False); + Assert.That(secondOperation.WasDisposed, Is.True); + Assert.That(secondOperation.WasApplied, Is.False); + }); } [Test] @@ -214,9 +226,12 @@ public async Task Should_execute_operations_with_same_partition_key_together() await storageSession.CompleteAsync(); - Assert.That(firstOperation.WasApplied, Is.True); - Assert.That(secondOperation.WasApplied, Is.True); - Assert.That(firstOperation.AppliedBatch, Is.EqualTo(secondOperation.AppliedBatch), "Operations with the same partition key must be in the same batch"); + Assert.Multiple(() => + { + Assert.That(firstOperation.WasApplied, Is.True); + Assert.That(secondOperation.WasApplied, Is.True); + Assert.That(firstOperation.AppliedBatch, Is.EqualTo(secondOperation.AppliedBatch), "Operations with the same partition key must be in the same batch"); + }); } [Test] @@ -251,14 +266,17 @@ public async Task Should_execute_with_outbox_transaction_operations_with_same_pa await outboxTransaction.Commit(); - Assert.That(firstOperationWasApplied, Is.False); - Assert.That(secondOperationWasApplied, Is.False); - Assert.That(firstOperationAppliedBatch, Is.Null); - Assert.That(secondOperationAppliedBatch, Is.Null); - - Assert.That(firstOperation.WasApplied, Is.True); - Assert.That(secondOperation.WasApplied, Is.True); - Assert.That(firstOperation.AppliedBatch, Is.EqualTo(secondOperation.AppliedBatch), "Operations with the same partition key must be in the same batch"); + Assert.Multiple(() => + { + Assert.That(firstOperationWasApplied, Is.False); + Assert.That(secondOperationWasApplied, Is.False); + Assert.That(firstOperationAppliedBatch, Is.Null); + Assert.That(secondOperationAppliedBatch, Is.Null); + + Assert.That(firstOperation.WasApplied, Is.True); + Assert.That(secondOperation.WasApplied, Is.True); + Assert.That(firstOperation.AppliedBatch, Is.EqualTo(secondOperation.AppliedBatch), "Operations with the same partition key must be in the same batch"); + }); } [Test] @@ -285,9 +303,12 @@ public async Task Should_execute_operations_with_different_partition_key_distinc await storageSession.CompleteAsync(); - Assert.That(firstOperation.WasApplied, Is.True); - Assert.That(secondOperation.WasApplied, Is.True); - Assert.That(firstOperation.AppliedBatch, Is.Not.EqualTo(secondOperation.AppliedBatch), "Operations with the different partition keys cannot be in the same batch"); + Assert.Multiple(() => + { + Assert.That(firstOperation.WasApplied, Is.True); + Assert.That(secondOperation.WasApplied, Is.True); + Assert.That(firstOperation.AppliedBatch, Is.Not.EqualTo(secondOperation.AppliedBatch), "Operations with the different partition keys cannot be in the same batch"); + }); } [Test] @@ -322,14 +343,17 @@ public async Task Should_execute_with_outbox_transaction_operations_with_differe await outboxTransaction.Commit(); - Assert.That(firstOperationWasApplied, Is.False); - Assert.That(secondOperationWasApplied, Is.False); - Assert.That(firstOperationAppliedBatch, Is.Null); - Assert.That(secondOperationAppliedBatch, Is.Null); - - Assert.That(firstOperation.WasApplied, Is.True); - Assert.That(secondOperation.WasApplied, Is.True); - Assert.That(firstOperation.AppliedBatch, Is.Not.EqualTo(secondOperation.AppliedBatch), "Operations with the different partition keys cannot be in the same batch"); + Assert.Multiple(() => + { + Assert.That(firstOperationWasApplied, Is.False); + Assert.That(secondOperationWasApplied, Is.False); + Assert.That(firstOperationAppliedBatch, Is.Null); + Assert.That(secondOperationAppliedBatch, Is.Null); + + Assert.That(firstOperation.WasApplied, Is.True); + Assert.That(secondOperation.WasApplied, Is.True); + Assert.That(firstOperation.AppliedBatch, Is.Not.EqualTo(secondOperation.AppliedBatch), "Operations with the different partition keys cannot be in the same batch"); + }); } [Test] @@ -356,10 +380,13 @@ public async Task Should_dispose_release_operations_when_operations_successful() await storageSession.CompleteAsync(); - Assert.That(operation.WasApplied, Is.True); - Assert.That(operation.WasDisposed, Is.False); - Assert.That(releaseOperation.WasApplied, Is.False); - Assert.That(releaseOperation.WasDisposed, Is.True); + Assert.Multiple(() => + { + Assert.That(operation.WasApplied, Is.True); + Assert.That(operation.WasDisposed, Is.False); + Assert.That(releaseOperation.WasApplied, Is.False); + Assert.That(releaseOperation.WasDisposed, Is.True); + }); } [Test] @@ -394,15 +421,18 @@ public async Task Should_dispose_release_operations_on_outbox_transaction_commit await outboxTransaction.Commit(); - Assert.That(operationWasApplied, Is.False); - Assert.That(operationWasDisposed, Is.False); - Assert.That(releaseOperationWasApplied, Is.False); - Assert.That(releaseOperationWasDisposed, Is.False); - - Assert.That(operation.WasApplied, Is.True); - Assert.That(operation.WasDisposed, Is.False); - Assert.That(releaseOperation.WasApplied, Is.False); - Assert.That(releaseOperation.WasDisposed, Is.True); + Assert.Multiple(() => + { + Assert.That(operationWasApplied, Is.False); + Assert.That(operationWasDisposed, Is.False); + Assert.That(releaseOperationWasApplied, Is.False); + Assert.That(releaseOperationWasDisposed, Is.False); + + Assert.That(operation.WasApplied, Is.True); + Assert.That(operation.WasDisposed, Is.False); + Assert.That(releaseOperation.WasApplied, Is.False); + Assert.That(releaseOperation.WasDisposed, Is.True); + }); } [Test] @@ -430,8 +460,11 @@ public async Task Should_not_execute_release_operations_when_operations_successf await storageSession.CompleteAsync(); storageSession.Dispose(); - Assert.That(releaseOperation.WasApplied, Is.False); - Assert.That(releaseOperation.WasDisposed, Is.True); + Assert.Multiple(() => + { + Assert.That(releaseOperation.WasApplied, Is.False); + Assert.That(releaseOperation.WasDisposed, Is.True); + }); } [Test] @@ -466,11 +499,14 @@ public async Task Should_not_execute_release_operations_on_outbox_transaction_co await outboxTransaction.Commit(); outboxTransaction.Dispose(); - Assert.That(releaseOperationWasApplied, Is.False); - Assert.That(releaseOperationWasDisposed, Is.False); + Assert.Multiple(() => + { + Assert.That(releaseOperationWasApplied, Is.False); + Assert.That(releaseOperationWasDisposed, Is.False); - Assert.That(releaseOperation.WasApplied, Is.False); - Assert.That(releaseOperation.WasDisposed, Is.True); + Assert.That(releaseOperation.WasApplied, Is.False); + Assert.That(releaseOperation.WasDisposed, Is.True); + }); } [Test] @@ -498,11 +534,14 @@ public async Task Should_execute_and_dispose_release_operations_with_same_partit storageSession.Dispose(); - Assert.That(firstReleaseOperation.WasApplied, Is.True); - Assert.That(secondReleaseOperation.WasApplied, Is.True); - Assert.That(firstReleaseOperation.WasDisposed, Is.True); - Assert.That(secondReleaseOperation.WasDisposed, Is.True); - Assert.That(firstReleaseOperation.AppliedBatch, Is.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the same partition key must be in the same batch"); + Assert.Multiple(() => + { + Assert.That(firstReleaseOperation.WasApplied, Is.True); + Assert.That(secondReleaseOperation.WasApplied, Is.True); + Assert.That(firstReleaseOperation.WasDisposed, Is.True); + Assert.That(secondReleaseOperation.WasDisposed, Is.True); + Assert.That(firstReleaseOperation.AppliedBatch, Is.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the same partition key must be in the same batch"); + }); } [Test] @@ -540,18 +579,21 @@ public async Task Should_execute_and_dispose_release_operations_on_outbox_transa outboxTransaction.Dispose(); - Assert.That(firstReleaseOperationWasApplied, Is.False); - Assert.That(secondReleaseOperationWasApplied, Is.False); - Assert.That(firstReleaseOperationWasDisposed, Is.False); - Assert.That(secondReleaseOperationWasDisposed, Is.False); - Assert.That(firstReleaseOperationAppliedBatch, Is.Null); - Assert.That(secondReleaseOperationAppliedBatch, Is.Null); - - Assert.That(firstReleaseOperation.WasApplied, Is.True); - Assert.That(secondReleaseOperation.WasApplied, Is.True); - Assert.That(firstReleaseOperation.WasDisposed, Is.True); - Assert.That(secondReleaseOperation.WasDisposed, Is.True); - Assert.That(firstReleaseOperation.AppliedBatch, Is.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the same partition key must be in the same batch"); + Assert.Multiple(() => + { + Assert.That(firstReleaseOperationWasApplied, Is.False); + Assert.That(secondReleaseOperationWasApplied, Is.False); + Assert.That(firstReleaseOperationWasDisposed, Is.False); + Assert.That(secondReleaseOperationWasDisposed, Is.False); + Assert.That(firstReleaseOperationAppliedBatch, Is.Null); + Assert.That(secondReleaseOperationAppliedBatch, Is.Null); + + Assert.That(firstReleaseOperation.WasApplied, Is.True); + Assert.That(secondReleaseOperation.WasApplied, Is.True); + Assert.That(firstReleaseOperation.WasDisposed, Is.True); + Assert.That(secondReleaseOperation.WasDisposed, Is.True); + Assert.That(firstReleaseOperation.AppliedBatch, Is.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the same partition key must be in the same batch"); + }); } [Test] @@ -582,10 +624,13 @@ public async Task Should_execute_and_dispose_release_operations_as_best_effort() Assert.DoesNotThrow(() => storageSession.Dispose()); - Assert.That(firstReleaseOperation.WasApplied, Is.True); - Assert.That(secondReleaseOperation.WasApplied, Is.True); - Assert.That(firstReleaseOperation.WasDisposed, Is.True); - Assert.That(secondReleaseOperation.WasDisposed, Is.True); + Assert.Multiple(() => + { + Assert.That(firstReleaseOperation.WasApplied, Is.True); + Assert.That(secondReleaseOperation.WasApplied, Is.True); + Assert.That(firstReleaseOperation.WasDisposed, Is.True); + Assert.That(secondReleaseOperation.WasDisposed, Is.True); + }); } [Test] @@ -619,10 +664,13 @@ public async Task Should_execute_and_dispose_release_operations_on_outbox_transa Assert.DoesNotThrow(() => outboxTransaction.Dispose()); - Assert.That(firstReleaseOperation.WasApplied, Is.True); - Assert.That(secondReleaseOperation.WasApplied, Is.True); - Assert.That(firstReleaseOperation.WasDisposed, Is.True); - Assert.That(secondReleaseOperation.WasDisposed, Is.True); + Assert.Multiple(() => + { + Assert.That(firstReleaseOperation.WasApplied, Is.True); + Assert.That(secondReleaseOperation.WasApplied, Is.True); + Assert.That(firstReleaseOperation.WasDisposed, Is.True); + Assert.That(secondReleaseOperation.WasDisposed, Is.True); + }); } [Test] @@ -650,11 +698,14 @@ public async Task Should_execute_and_dispose_release_operations_with_different_p storageSession.Dispose(); - Assert.That(firstReleaseOperation.WasApplied, Is.True); - Assert.That(secondReleaseOperation.WasApplied, Is.True); - Assert.That(firstReleaseOperation.WasDisposed, Is.True); - Assert.That(secondReleaseOperation.WasDisposed, Is.True); - Assert.That(firstReleaseOperation.AppliedBatch, Is.Not.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the different partition keys must be in different batches."); + Assert.Multiple(() => + { + Assert.That(firstReleaseOperation.WasApplied, Is.True); + Assert.That(secondReleaseOperation.WasApplied, Is.True); + Assert.That(firstReleaseOperation.WasDisposed, Is.True); + Assert.That(secondReleaseOperation.WasDisposed, Is.True); + Assert.That(firstReleaseOperation.AppliedBatch, Is.Not.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the different partition keys must be in different batches."); + }); } [Test] @@ -692,18 +743,21 @@ public async Task Should_execute_and_dispose_release_operations_on_outbox_transa outboxTransaction.Dispose(); - Assert.That(firstReleaseOperationWasApplied, Is.False); - Assert.That(secondReleaseOperationWasApplied, Is.False); - Assert.That(firstReleaseOperationWasDisposed, Is.False); - Assert.That(secondReleaseOperationWasDisposed, Is.False); - Assert.That(firstReleaseOperationAppliedBatch, Is.Null); - Assert.That(secondReleaseOperationAppliedBatch, Is.Null); - - Assert.That(firstReleaseOperation.WasApplied, Is.True); - Assert.That(secondReleaseOperation.WasApplied, Is.True); - Assert.That(firstReleaseOperation.WasDisposed, Is.True); - Assert.That(secondReleaseOperation.WasDisposed, Is.True); - Assert.That(firstReleaseOperation.AppliedBatch, Is.Not.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the different partition keys must be in different batches."); + Assert.Multiple(() => + { + Assert.That(firstReleaseOperationWasApplied, Is.False); + Assert.That(secondReleaseOperationWasApplied, Is.False); + Assert.That(firstReleaseOperationWasDisposed, Is.False); + Assert.That(secondReleaseOperationWasDisposed, Is.False); + Assert.That(firstReleaseOperationAppliedBatch, Is.Null); + Assert.That(secondReleaseOperationAppliedBatch, Is.Null); + + Assert.That(firstReleaseOperation.WasApplied, Is.True); + Assert.That(secondReleaseOperation.WasApplied, Is.True); + Assert.That(firstReleaseOperation.WasDisposed, Is.True); + Assert.That(secondReleaseOperation.WasDisposed, Is.True); + Assert.That(firstReleaseOperation.AppliedBatch, Is.Not.EqualTo(secondReleaseOperation.AppliedBatch), "Release operations with the different partition keys must be in different batches."); + }); } [Test] @@ -729,8 +783,11 @@ public async Task Should_not_dispose_release_operations_when_operations_not_succ storageSession.AddOperation(releaseOperation); Assert.That(async () => await storageSession.CompleteAsync(), Throws.Exception); - Assert.That(releaseOperation.WasApplied, Is.False); - Assert.That(releaseOperation.WasDisposed, Is.False); + Assert.Multiple(() => + { + Assert.That(releaseOperation.WasApplied, Is.False); + Assert.That(releaseOperation.WasDisposed, Is.False); + }); } [Test] @@ -759,8 +816,11 @@ public async Task Should_not_dispose_release_operations_on_outbox_transaction_co await storageSession.CompleteAsync(); Assert.That(async () => await outboxTransaction.Commit(), Throws.Exception); - Assert.That(releaseOperation.WasApplied, Is.False); - Assert.That(releaseOperation.WasDisposed, Is.False); + Assert.Multiple(() => + { + Assert.That(releaseOperation.WasApplied, Is.False); + Assert.That(releaseOperation.WasDisposed, Is.False); + }); } class ThrowOnApplyOperation : FakeOperation diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/TestableCosmosSynchronizedStorageSessionTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/TestableCosmosSynchronizedStorageSessionTests.cs index 6b86b85f..2a5cb8e0 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/TestableCosmosSynchronizedStorageSessionTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/SynchronizedStorage/TestableCosmosSynchronizedStorageSessionTests.cs @@ -29,7 +29,7 @@ public async Task CanBeUsed() var handler = new HandlerUsingSynchronizedStorageSessionExtension(); await handler.Handle(new MyMessage(), handlerContext); - Assert.IsNotEmpty(transactionalBatch.CreatedItems.OfType()); + Assert.That(transactionalBatch.CreatedItems.OfType(), Is.Not.Empty); } class FakeTransactionalBatch : TransactionalBatch diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/ContainerInformationExtractorTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/ContainerInformationExtractorTests.cs index 10214f70..a2a3b73a 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/ContainerInformationExtractorTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/ContainerInformationExtractorTests.cs @@ -28,8 +28,11 @@ public void Should_not_extract_from_header_with_no_matching_key() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.False); - Assert.That(partitionKey, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(partitionKey, Is.Null); + }); } [Test] @@ -46,8 +49,11 @@ public void Should_extract_from_header_with_first_match_winning() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + }); } [Test] @@ -59,8 +65,11 @@ public void Should_extract_from_header_with_fixed_container() var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.True); - Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("FixedValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("FixedValue", fakePartitionKeyPath))); + }); } [Test] @@ -73,8 +82,11 @@ public void Should_extract_from_header_with_key_and_extractor() var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.True); - Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + }); } [Test] @@ -87,8 +99,11 @@ public void Should_extract_from_header_with_key_and_extractor_and_extractor_argu var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.True); - Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + }); } [Test] @@ -101,8 +116,11 @@ public void Should_extract_from_headers_with_extractor() var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.True); - Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + }); } [Test] @@ -114,8 +132,11 @@ public void Should_extract_from_headers_with_extractor_and_allow_null() var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.False); - Assert.That(containerInformation, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(containerInformation, Is.Null); + }); } [Test] @@ -128,8 +149,11 @@ public void Should_extract_from_headers_with_extractor_and_extractor_argument() var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.True); - Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + }); } [Test] @@ -141,8 +165,11 @@ public void Should_extract_from_headers_with_extractor_and_extractor_argument_an var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.False); - Assert.That(containerInformation, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(containerInformation, Is.Null); + }); } [Test] @@ -154,8 +181,11 @@ public void Should_extract_from_headers_with_custom_implementation() var wasExtracted = extractor.TryExtract(headers, out var containerInformation); - Assert.That(wasExtracted, Is.True); - Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(containerInformation, Is.Not.Null.And.EqualTo(new ContainerInformation("HeaderValue", fakePartitionKeyPath))); + }); } class CustomHeadersExtractor : IContainerInformationFromHeadersExtractor @@ -192,8 +222,11 @@ public void Should_not_extract_from_message_with_no_match() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var containerInformation); - Assert.That(wasExtracted, Is.False); - Assert.That(containerInformation, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(containerInformation, Is.Null); + }); } [Test] @@ -206,8 +239,11 @@ public void Should_extract_from_message_with_first_match_winning() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SomeValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SomeValue", fakePartitionKeyPath))); + }); } [Test] @@ -219,8 +255,11 @@ public void Should_extract_from_message() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SomeValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SomeValue", fakePartitionKeyPath))); + }); } [Test] @@ -232,8 +271,11 @@ public void Should_extract_from_message_with_fixed_container() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("FixedValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("FixedValue", fakePartitionKeyPath))); + }); } [Test] @@ -245,8 +287,11 @@ public void Should_extract_from_message_with_argument() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SOMEVALUE", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SOMEVALUE", fakePartitionKeyPath))); + }); } [Test] @@ -260,8 +305,11 @@ public void Should_extract_from_message_with_headers() var wasExtracted = extractor.TryExtract(message, headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SOMEVALUE_HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SOMEVALUE_HeaderValue", fakePartitionKeyPath))); + }); } [Test] @@ -275,8 +323,11 @@ public void Should_extract_from_message_with_headers_and_argument() var wasExtracted = extractor.TryExtract(message, headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SomeValue_HeaderValue", fakePartitionKeyPath))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new ContainerInformation("SomeValue_HeaderValue", fakePartitionKeyPath))); + }); } [Test] diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/PartitionKeyExtractorTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/PartitionKeyExtractorTests.cs index 712d507c..35483a37 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/PartitionKeyExtractorTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/PartitionKeyExtractorTests.cs @@ -26,8 +26,11 @@ public void Should_not_extract_from_header_with_no_matching_key() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.False); - Assert.That(partitionKey, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(partitionKey, Is.Null); + }); } [Test] @@ -44,8 +47,11 @@ public void Should_extract_from_header_with_first_match_winning() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -57,8 +63,11 @@ public void Should_extract_from_header_with_key() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -70,8 +79,11 @@ public void Should_extract_from_header_with_key_and_extractor() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -83,8 +95,11 @@ public void Should_extract_from_header_with_key_and_extractor_with_partition_key var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -96,8 +111,11 @@ public void Should_extract_from_header_with_key_extractor_and_argument() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -109,8 +127,11 @@ public void Should_extract_from_headers_with_extractor() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -122,8 +143,11 @@ public void Should_extract_from_headers_with_extractor_and_allow_null() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.False); - Assert.That(partitionKey, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(partitionKey, Is.Null); + }); } [Test] @@ -135,8 +159,11 @@ public void Should_extract_from_headers_with_extractor_and_argument() var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -148,8 +175,11 @@ public void Should_extract_from_headers_with_extractor_and_argument_and_allow_nu var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.False); - Assert.That(partitionKey, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(partitionKey, Is.Null); + }); } [Test] @@ -161,8 +191,11 @@ public void Should_extract_from_header_with_key_converter_partition_key_and_argu var wasExtracted = extractor.TryExtract(headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("HeaderValue"))); + }); } [Test] @@ -185,8 +218,11 @@ public void Should_not_extract_from_message_with_no_match() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.False); - Assert.That(partitionKey, Is.Null); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.False); + Assert.That(partitionKey, Is.Null); + }); } [Test] @@ -199,8 +235,11 @@ public void Should_extract_from_message_with_first_match_winning() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SomeValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SomeValue"))); + }); } [Test] @@ -212,8 +251,11 @@ public void Should_extract_from_message() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SomeValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SomeValue"))); + }); } [Test] @@ -225,8 +267,11 @@ public void Should_extract_from_message_with_argument() var wasExtracted = extractor.TryExtract(message, new Dictionary(), out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SOMEVALUE"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SOMEVALUE"))); + }); } [Test] @@ -240,8 +285,11 @@ public void Should_extract_from_message_with_headers() var wasExtracted = extractor.TryExtract(message, headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SOMEVALUE_HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SOMEVALUE_HeaderValue"))); + }); } [Test] @@ -255,8 +303,11 @@ public void Should_extract_from_message_with_headers_and_argument() var wasExtracted = extractor.TryExtract(message, headers, out var partitionKey); - Assert.That(wasExtracted, Is.True); - Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SomeValue_HeaderValue"))); + Assert.Multiple(() => + { + Assert.That(wasExtracted, Is.True); + Assert.That(partitionKey, Is.Not.Null.And.EqualTo(new PartitionKey("SomeValue_HeaderValue"))); + }); } [Test] diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeTheLogicalOutboxBehaviorTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeTheLogicalOutboxBehaviorTests.cs index a205d2aa..12ace744 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeTheLogicalOutboxBehaviorTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeTheLogicalOutboxBehaviorTests.cs @@ -46,8 +46,11 @@ public async Task Should_set_partition_key_when_partition_key_extractor_returns_ await behavior.Invoke(context, _ => Task.CompletedTask); - Assert.That(context.Extensions.TryGet(out var partitionKey), Is.True); - Assert.AreEqual(new PartitionKey(true), partitionKey); + Assert.Multiple(() => + { + Assert.That(context.Extensions.TryGet(out var partitionKey), Is.True); + Assert.That(partitionKey, Is.EqualTo(new PartitionKey(true))); + }); } [Test] @@ -85,8 +88,11 @@ public async Task Should_set_container_when_container_information_extractor_retu await behavior.Invoke(context, _ => Task.CompletedTask); - Assert.That(context.Extensions.TryGet(out var containerInformation), Is.True); - Assert.AreEqual(new ContainerInformation("containerName", new PartitionKeyPath("/deep/down")), containerInformation); + Assert.Multiple(() => + { + Assert.That(context.Extensions.TryGet(out var containerInformation), Is.True); + Assert.That(containerInformation, Is.EqualTo(new ContainerInformation("containerName", new PartitionKeyPath("/deep/down")))); + }); } [Test] @@ -115,8 +121,11 @@ public async Task Should_pass_message_and_headers_to_partition_key_extractor() await behavior.Invoke(context, _ => Task.CompletedTask); - Assert.That(capturedMessageInstanceFromPartionKeyExtractor, Is.Not.Null.And.EqualTo(messageInstance)); - Assert.That(capturedHeadersFromPartionKeyExtractor, Is.Not.Null.And.EqualTo(messageHeaders)); + Assert.Multiple(() => + { + Assert.That(capturedMessageInstanceFromPartionKeyExtractor, Is.Not.Null.And.EqualTo(messageInstance)); + Assert.That(capturedHeadersFromPartionKeyExtractor, Is.Not.Null.And.EqualTo(messageHeaders)); + }); } [Test] @@ -146,8 +155,11 @@ public async Task Should_pass_message_and_headers_to_container_information_extra await behavior.Invoke(context, _ => Task.CompletedTask); - Assert.That(capturedMessageInstanceFromContainerInformationExtractor, Is.Not.Null.And.EqualTo(messageInstance)); - Assert.That(capturedHeadersFromContainerInformationExtractor, Is.Not.Null.And.EqualTo(messageHeaders)); + Assert.Multiple(() => + { + Assert.That(capturedMessageInstanceFromContainerInformationExtractor, Is.Not.Null.And.EqualTo(messageInstance)); + Assert.That(capturedHeadersFromContainerInformationExtractor, Is.Not.Null.And.EqualTo(messageHeaders)); + }); } delegate bool TryExtractPartitionKey(object message, IReadOnlyDictionary headers, out PartitionKey? partitionKey); diff --git a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeThePhysicalOutboxBehaviorTests.cs b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeThePhysicalOutboxBehaviorTests.cs index cf44801b..adfa8c23 100644 --- a/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeThePhysicalOutboxBehaviorTests.cs +++ b/src/NServiceBus.Persistence.CosmosDB.Tests/Transaction/TransactionInformationBeforeThePhysicalOutboxBehaviorTests.cs @@ -44,8 +44,11 @@ public async Task Should_set_partition_key_when_partition_key_extractor_returns_ await behavior.Invoke(context, _ => Task.CompletedTask); - Assert.That(context.Extensions.TryGet(out var partitionKey), Is.True); - Assert.AreEqual(new PartitionKey(true), partitionKey); + Assert.Multiple(() => + { + Assert.That(context.Extensions.TryGet(out var partitionKey), Is.True); + Assert.That(partitionKey, Is.EqualTo(new PartitionKey(true))); + }); } [Test] @@ -83,8 +86,11 @@ public async Task Should_set_container_when_container_information_extractor_retu await behavior.Invoke(context, _ => Task.CompletedTask); - Assert.That(context.Extensions.TryGet(out var containerInformation), Is.True); - Assert.AreEqual(new ContainerInformation("containerName", new PartitionKeyPath("/deep/down")), containerInformation); + Assert.Multiple(() => + { + Assert.That(context.Extensions.TryGet(out var containerInformation), Is.True); + Assert.That(containerInformation, Is.EqualTo(new ContainerInformation("containerName", new PartitionKeyPath("/deep/down")))); + }); } [Test] diff --git a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj index 983a81ea..6b21cbcc 100644 --- a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests.csproj @@ -19,7 +19,8 @@ - + + diff --git a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/When_using_transactional_session.cs b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/When_using_transactional_session.cs index f85be852..f3b312cf 100644 --- a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/When_using_transactional_session.cs +++ b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.AcceptanceTests/When_using_transactional_session.cs @@ -42,8 +42,8 @@ public async Task Should_send_messages_and_store_document_in_synchronized_sessio var response = await SetupFixture.Container.ReadItemAsync(documentId, new PartitionKey(context.TestRunId.ToString())); - Assert.IsNotNull(response); - Assert.AreEqual("SomeData", response.Resource.Data); + Assert.That(response, Is.Not.Null); + Assert.That(response.Resource.Data, Is.EqualTo("SomeData")); } [TestCase(true)] @@ -76,8 +76,8 @@ public async Task Should_send_messages_and_store_document_in_cosmos_session_on_t var response = await SetupFixture.Container.ReadItemAsync(documentId, new PartitionKey(context.TestRunId.ToString())); - Assert.IsNotNull(response); - Assert.AreEqual("SomeData", response.Resource.Data); + Assert.That(response, Is.Not.Null); + Assert.That(response.Resource.Data, Is.EqualTo("SomeData")); } [TestCase(true)] @@ -117,7 +117,7 @@ public async Task Should_not_send_messages_if_session_is_not_committed(bool outb var exception = Assert.ThrowsAsync(async () => await SetupFixture.Container.ReadItemAsync(documentId, new PartitionKey(context.TestRunId.ToString()))); - Assert.AreEqual(HttpStatusCode.NotFound, exception.StatusCode); + Assert.That(exception.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); } [TestCase(true)] diff --git a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj index 4c0e5c4f..d9374432 100644 --- a/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj +++ b/src/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests/NServiceBus.Persistence.CosmosDB.TransactionalSession.Tests.csproj @@ -13,7 +13,8 @@ - + + diff --git a/src/SharedAcceptanceTests.All/When_custom_provider_registered.cs b/src/SharedAcceptanceTests.All/When_custom_provider_registered.cs index 139f4d69..7fd1ee27 100644 --- a/src/SharedAcceptanceTests.All/When_custom_provider_registered.cs +++ b/src/SharedAcceptanceTests.All/When_custom_provider_registered.cs @@ -22,7 +22,7 @@ public async Task Should_be_used() .Done(c => c.SagaReceivedMessage) .Run(); - Assert.True(context.ProviderWasCalled); + Assert.That(context.ProviderWasCalled, Is.True); } public class Context : ScenarioContext diff --git a/src/SharedAcceptanceTests.All/When_default_credentials_used.cs b/src/SharedAcceptanceTests.All/When_default_credentials_used.cs index 28099711..ef2d4d69 100644 --- a/src/SharedAcceptanceTests.All/When_default_credentials_used.cs +++ b/src/SharedAcceptanceTests.All/When_default_credentials_used.cs @@ -27,7 +27,7 @@ public async Task Should_work() .Done(c => c.SagaReceivedMessage) .Run(); - Assert.True(context.SagaReceivedMessage); + Assert.That(context.SagaReceivedMessage, Is.True); } public class Context : ScenarioContext diff --git a/src/SharedAcceptanceTests.All/When_regular_handler_with_no_container_information.cs b/src/SharedAcceptanceTests.All/When_regular_handler_with_no_container_information.cs index 2376d722..f0b63450 100644 --- a/src/SharedAcceptanceTests.All/When_regular_handler_with_no_container_information.cs +++ b/src/SharedAcceptanceTests.All/When_regular_handler_with_no_container_information.cs @@ -21,7 +21,7 @@ public async Task Should_work() .Done(c => c.MessageReceived) .Run(runSettings); - Assert.True(context.MessageReceived); + Assert.That(context.MessageReceived, Is.True); } public class Context : ScenarioContext diff --git a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_outbox_synchronized_session_via_container.cs b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_outbox_synchronized_session_via_container.cs index 9428ea02..013315bb 100644 --- a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_outbox_synchronized_session_via_container.cs +++ b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_outbox_synchronized_session_via_container.cs @@ -19,8 +19,11 @@ public async Task Should_inject_synchronized_session_into_handler() .Run() .ConfigureAwait(false); - Assert.True(context.RepositoryHasBatch); - Assert.True(context.RepositoryHasContainer); + Assert.Multiple(() => + { + Assert.That(context.RepositoryHasBatch, Is.True); + Assert.That(context.RepositoryHasContainer, Is.True); + }); AssertPartitionPart(context); } diff --git a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container.cs b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container.cs index 88298367..013cd68f 100644 --- a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container.cs +++ b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container.cs @@ -17,7 +17,7 @@ public async Task Should_inject_synchronized_session_into_handler() .Run() .ConfigureAwait(false); - Assert.True(context.HandlerHasBatch); + Assert.That(context.HandlerHasBatch, Is.True); } public class Context : ScenarioContext diff --git a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_extension.cs b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_extension.cs index d2ebed12..afacca66 100644 --- a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_extension.cs +++ b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_extension.cs @@ -19,7 +19,7 @@ await Scenario.Define() .Run() .ConfigureAwait(false); - Assert.AreEqual(1, TransactionalBatchCounterHandler.TotalTransactionalBatches, "Expected to have a single transactional batch but found more."); + Assert.That(TransactionalBatchCounterHandler.TotalTransactionalBatches, Is.EqualTo(1), "Expected to have a single transactional batch but found more."); } public class Context : ScenarioContext diff --git a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_fails.cs b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_fails.cs index 3303becf..fa11eaf3 100644 --- a/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_fails.cs +++ b/src/SharedAcceptanceTests.RequirePartitionKey/When_using_synchronized_session_via_container_and_storage_session_fails.cs @@ -24,7 +24,7 @@ await Scenario.Define() .Run() .ConfigureAwait(false); - Assert.AreEqual(0, TransactionalBatchCounterHandler.TotalTransactionalBatches, "Expected to have no transactional batch but found one."); + Assert.That(TransactionalBatchCounterHandler.TotalTransactionalBatches, Is.EqualTo(0), "Expected to have no transactional batch but found one."); } public class Context : ScenarioContext