From 405ba5e3a52e31f17c7d8a30e0b6e856bd7c5552 Mon Sep 17 00:00:00 2001
From: "Jeremy D. Miller" <jeremydmiller@yahoo.com>
Date: Mon, 21 Oct 2024 14:41:44 -0500
Subject: [PATCH] Replaced old custom Exception.ShouldThrow**** with Shouldly

---
 ...ate_none_is_disabling_schema_validation.cs |  7 ++--
 .../event_projection_scenario_tests.cs        | 10 ++---
 ...nsive_programming_checks_on_bad_id_type.cs | 15 +++----
 .../Bugs/Bug_953_too_long_index_names.cs      |  3 +-
 ...timistic_concurrency_with_update_method.cs |  2 +-
 .../Concurrency/optimistic_concurrency.cs     |  8 ++--
 .../Configuration/DocumentMappingTests.cs     |  4 +-
 .../ForeignKeys/foreign_keys.cs               |  2 +-
 .../assigning_versions_to_documents.cs        |  4 +-
 .../disabling_default_tenant_usage.cs         | 13 +++---
 .../Reading/Json/streaming_json_results.cs    | 14 +++----
 .../identity_map_mechanics.cs                 |  2 +-
 .../SessionMechanics/session_timeouts.cs      |  7 ++--
 .../Writing/Identity/using_string_identity.cs |  4 +-
 .../Writing/document_updates.cs               |  2 +-
 ...duplicate_document_type_alias_detection.cs |  2 +-
 .../Aggregation/CustomProjectionTests.cs      |  6 +--
 .../fetching_async_aggregates_for_writing.cs  |  2 +-
 .../fetching_inline_aggregates_for_writing.cs |  2 +-
 ...d_event_capture_and_fetching_the_stream.cs |  2 +-
 ...t_capture_and_fetching_the_stream_Tests.cs |  5 +--
 .../Acceptance/statistics_and_paged_list.cs   |  6 +--
 .../Bug_118_bad_exception_message_Tests.cs    |  3 +-
 .../query_against_child_collections.cs        | 11 ++---
 src/LinqTests/Operators/first_operator.cs     |  4 +-
 src/LinqTests/Operators/last_operator.cs      | 11 +++--
 src/LinqTests/Operators/single_operator.cs    | 12 +++---
 .../Harness/SpecificationExtensions.cs        | 42 -------------------
 28 files changed, 84 insertions(+), 121 deletions(-)

diff --git a/src/CoreTests/Bugs/Bug_983_autocreate_none_is_disabling_schema_validation.cs b/src/CoreTests/Bugs/Bug_983_autocreate_none_is_disabling_schema_validation.cs
index 238b53c6f2..d4dd23df23 100644
--- a/src/CoreTests/Bugs/Bug_983_autocreate_none_is_disabling_schema_validation.cs
+++ b/src/CoreTests/Bugs/Bug_983_autocreate_none_is_disabling_schema_validation.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Threading.Tasks;
 using Marten.Testing.Harness;
+using Shouldly;
 using Weasel.Core;
 using Weasel.Core.Migrations;
 using Xunit;
@@ -25,10 +26,10 @@ public async Task should_be_validating_the_new_doc_does_not_exist()
             cfg.AutoCreateSchemaObjects = AutoCreate.None;
         });
 
-        await Exception<DatabaseValidationException>.ShouldBeThrownByAsync(() =>
+        await Should.ThrowAsync<DatabaseValidationException>(async () =>
         {
-            return theStore.Storage.Database.AssertDatabaseMatchesConfigurationAsync();
+            await theStore.Storage.Database.AssertDatabaseMatchesConfigurationAsync();
         });
     }
 
-}
\ No newline at end of file
+}
diff --git a/src/DaemonTests/event_projection_scenario_tests.cs b/src/DaemonTests/event_projection_scenario_tests.cs
index 3d19b81ec0..3829645925 100644
--- a/src/DaemonTests/event_projection_scenario_tests.cs
+++ b/src/DaemonTests/event_projection_scenario_tests.cs
@@ -86,7 +86,7 @@ public async Task sad_path_test_with_inline_projection()
             opts.Projections.Add(new UserProjection(), ProjectionLifecycle.Inline);
         });
 
-        await Exception<ProjectionScenarioException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<ProjectionScenarioException>(async () =>
         {
             await theStore.Advanced.EventProjectionScenario(scenario =>
             {
@@ -121,7 +121,7 @@ public async Task sad_path_test_with_inline_projection_with_document_assertion()
             opts.Projections.Add(new UserProjection(), ProjectionLifecycle.Inline);
         });
 
-        await Exception<ProjectionScenarioException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<ProjectionScenarioException>(async () =>
         {
             await theStore.Advanced.EventProjectionScenario(scenario =>
             {
@@ -186,7 +186,7 @@ public async Task sad_path_test_with_inline_projection_async()
             opts.Projections.Add(new UserProjection(), ProjectionLifecycle.Async);
         });
 
-        await Exception<ProjectionScenarioException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<ProjectionScenarioException>(async () =>
         {
             await theStore.Advanced.EventProjectionScenario(scenario =>
             {
@@ -221,7 +221,7 @@ public async Task sad_path_test_with_inline_projection_with_document_assertion_a
             opts.Projections.Add(new UserProjection(), ProjectionLifecycle.Async);
         });
 
-        await Exception<ProjectionScenarioException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<ProjectionScenarioException>(async () =>
         {
             await theStore.Advanced.EventProjectionScenario(scenario =>
             {
@@ -278,4 +278,4 @@ public void Project(DeleteUser deletion, IDocumentOperations operations)
     }
 }
 
-#endregion
\ No newline at end of file
+#endregion
diff --git a/src/DocumentDbTests/Bugs/Bug_648_defensive_programming_checks_on_bad_id_type.cs b/src/DocumentDbTests/Bugs/Bug_648_defensive_programming_checks_on_bad_id_type.cs
index 36ce384215..482ac5f34d 100644
--- a/src/DocumentDbTests/Bugs/Bug_648_defensive_programming_checks_on_bad_id_type.cs
+++ b/src/DocumentDbTests/Bugs/Bug_648_defensive_programming_checks_on_bad_id_type.cs
@@ -4,6 +4,7 @@
 using Marten.Services;
 using Marten.Testing.Documents;
 using Marten.Testing.Harness;
+using Shouldly;
 using Xunit;
 
 namespace DocumentDbTests.Bugs;
@@ -13,7 +14,7 @@ public class Bug_648_defensive_programming_checks_on_bad_id_type: IntegrationCon
     [Fact]
     public void try_to_load_a_guid_identified_type_with_wrong_type()
     {
-        Exception<DocumentIdTypeMismatchException>.ShouldBeThrownBy(() =>
+        Should.Throw<DocumentIdTypeMismatchException>(() =>
         {
             theSession.Load<Target>(111);
         });
@@ -22,16 +23,16 @@ public void try_to_load_a_guid_identified_type_with_wrong_type()
     [Fact]
     public Task try_to_load_a_guid_identified_type_with_wrong_type_async()
     {
-        return Exception<DocumentIdTypeMismatchException>.ShouldBeThrownByAsync(() =>
+        return Should.ThrowAsync<DocumentIdTypeMismatchException>(async () =>
         {
-            return theSession.LoadAsync<Target>(111);
+            await theSession.LoadAsync<Target>(111);
         });
     }
 
     [Fact]
     public void bad_id_to_load_many()
     {
-        Exception<DocumentIdTypeMismatchException>.ShouldBeThrownBy(() =>
+        Should.Throw<DocumentIdTypeMismatchException>(() =>
         {
             theSession.LoadMany<Target>(111, 121);
         });
@@ -40,13 +41,13 @@ public void bad_id_to_load_many()
     [Fact]
     public Task try_to_loadmany_a_guid_identified_type_with_wrong_type_async()
     {
-        return Exception<DocumentIdTypeMismatchException>.ShouldBeThrownByAsync(() =>
+        return Should.ThrowAsync<DocumentIdTypeMismatchException>(async () =>
         {
-            return theSession.LoadManyAsync<Target>(111, 222);
+            await theSession.LoadManyAsync<Target>(111, 222);
         });
     }
 
     public Bug_648_defensive_programming_checks_on_bad_id_type(DefaultStoreFixture fixture) : base(fixture)
     {
     }
-}
\ No newline at end of file
+}
diff --git a/src/DocumentDbTests/Bugs/Bug_953_too_long_index_names.cs b/src/DocumentDbTests/Bugs/Bug_953_too_long_index_names.cs
index be9f646380..ef26a2f705 100644
--- a/src/DocumentDbTests/Bugs/Bug_953_too_long_index_names.cs
+++ b/src/DocumentDbTests/Bugs/Bug_953_too_long_index_names.cs
@@ -1,6 +1,7 @@
 using System;
 using Marten.Exceptions;
 using Marten.Testing.Harness;
+using Shouldly;
 using Weasel.Postgresql;
 using Xunit;
 
@@ -24,7 +25,7 @@ public void can_ensure_storage_with_index_id_greater_than_63_bytes()
             _.NameDataLength = 64;
         });
 
-        Exception<PostgresqlIdentifierTooLongException>.ShouldBeThrownBy(() =>
+        Should.Throw<PostgresqlIdentifierTooLongException>(() =>
         {
             theStore.Tenancy.Default.Database.EnsureStorageExists(typeof(LongEnoughNameToCauseIdTruncation));
         });
diff --git a/src/DocumentDbTests/Bugs/optimistic_concurrency_with_update_method.cs b/src/DocumentDbTests/Bugs/optimistic_concurrency_with_update_method.cs
index 65f47abc90..ab2e8903e0 100644
--- a/src/DocumentDbTests/Bugs/optimistic_concurrency_with_update_method.cs
+++ b/src/DocumentDbTests/Bugs/optimistic_concurrency_with_update_method.cs
@@ -123,7 +123,7 @@ public async Task update_with_stale_version_throws_exception_async()
 
             session2.Update(doc2);
 
-            var ex = await Exception<ConcurrencyException>.ShouldBeThrownByAsync(async () =>
+            var ex = await Should.ThrowAsync<ConcurrencyException>(async () =>
             {
                 await session2.SaveChangesAsync();
             });
diff --git a/src/DocumentDbTests/Concurrency/optimistic_concurrency.cs b/src/DocumentDbTests/Concurrency/optimistic_concurrency.cs
index cd4b818e80..3fd09f73ac 100644
--- a/src/DocumentDbTests/Concurrency/optimistic_concurrency.cs
+++ b/src/DocumentDbTests/Concurrency/optimistic_concurrency.cs
@@ -233,7 +233,7 @@ public async Task update_with_stale_version_standard_async()
             // Should go through just fine
             await session2.SaveChangesAsync();
 
-            var ex = await Exception<ConcurrencyException>.ShouldBeThrownByAsync(async () =>
+            var ex = await Should.ThrowAsync<ConcurrencyException>(async () =>
             {
                 await session1.SaveChangesAsync();
             });
@@ -474,7 +474,7 @@ public async Task update_multiple_docs_at_a_time_sad_path_async()
                 await other.SaveChangesAsync();
             }
 
-            var ex = await Exception<AggregateException>.ShouldBeThrownByAsync(async () =>
+            var ex = await Should.ThrowAsync<AggregateException>(async () =>
             {
                 await session.SaveChangesAsync();
             });
@@ -589,7 +589,7 @@ public async Task store_with_the_right_version_sad_path_async()
             // Some random version that won't match
             session.UpdateExpectedVersion(doc1, Guid.NewGuid());
 
-            await Exception<ConcurrencyException>.ShouldBeThrownByAsync(async () =>
+            await Should.ThrowAsync<ConcurrencyException>(async () =>
             {
                 await session.SaveChangesAsync();
             });
@@ -797,7 +797,7 @@ public async Task update_with_stale_version_async()
             // Should go through just fine
             await session2.SaveChangesAsync();
 
-            var ex = await Exception<ConcurrencyException>.ShouldBeThrownByAsync(async () =>
+            var ex = await Should.ThrowAsync<ConcurrencyException>(async () =>
             {
                 await session1.SaveChangesAsync();
             });
diff --git a/src/DocumentDbTests/Configuration/DocumentMappingTests.cs b/src/DocumentDbTests/Configuration/DocumentMappingTests.cs
index 2e38da7856..b4b6eba8c2 100644
--- a/src/DocumentDbTests/Configuration/DocumentMappingTests.cs
+++ b/src/DocumentDbTests/Configuration/DocumentMappingTests.cs
@@ -533,7 +533,7 @@ public void to_upsert_with_subclasses()
     [Fact]
     public void trying_to_replace_the_hilo_settings_when_not_using_hilo_for_the_sequence_throws()
     {
-        Exception<InvalidOperationException>.ShouldBeThrownBy(
+        Should.Throw<InvalidOperationException>(
             () => { DocumentMapping.For<StringId>().HiloSettings = new HiloSettings(); });
     }
 
@@ -622,7 +622,7 @@ public void uses_ConfigureMarten_method_to_alter_mapping_upon_construction_with_
     [Fact]
     public void trying_to_index_deleted_at_when_not_soft_deleted_document_throws()
     {
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() => DocumentMapping.For<IntId>().AddDeletedAtIndex());
+        Should.Throw<InvalidOperationException>(() => DocumentMapping.For<IntId>().AddDeletedAtIndex());
     }
 
     [Fact]
diff --git a/src/DocumentDbTests/ForeignKeys/foreign_keys.cs b/src/DocumentDbTests/ForeignKeys/foreign_keys.cs
index 1fea155799..220d765da9 100644
--- a/src/DocumentDbTests/ForeignKeys/foreign_keys.cs
+++ b/src/DocumentDbTests/ForeignKeys/foreign_keys.cs
@@ -340,7 +340,7 @@ public async Task order_inserts()
     [Fact]
     public void throws_exception_on_cyclic_dependency()
     {
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
             StoreOptions(_ =>
             {
diff --git a/src/DocumentDbTests/Metadata/assigning_versions_to_documents.cs b/src/DocumentDbTests/Metadata/assigning_versions_to_documents.cs
index 41f1d56fa8..89902399e4 100644
--- a/src/DocumentDbTests/Metadata/assigning_versions_to_documents.cs
+++ b/src/DocumentDbTests/Metadata/assigning_versions_to_documents.cs
@@ -34,7 +34,7 @@ public void version_member_set_by_attribute()
     [Fact]
     public void wrong_version_member()
     {
-        Exception<ArgumentOutOfRangeException>.ShouldBeThrownBy(() =>
+        Should.Throw<ArgumentOutOfRangeException>(() =>
         {
             DocumentMapping.For<WrongVersionTypedDoc>();
         });
@@ -86,4 +86,4 @@ public class WrongVersionTypedDoc
 
     [Version]
     public string Version;
-}
\ No newline at end of file
+}
diff --git a/src/DocumentDbTests/MultiTenancy/disabling_default_tenant_usage.cs b/src/DocumentDbTests/MultiTenancy/disabling_default_tenant_usage.cs
index 89299f243e..302495bf6b 100644
--- a/src/DocumentDbTests/MultiTenancy/disabling_default_tenant_usage.cs
+++ b/src/DocumentDbTests/MultiTenancy/disabling_default_tenant_usage.cs
@@ -2,6 +2,7 @@
 using Marten.Services;
 using Marten.Storage;
 using Marten.Testing.Harness;
+using Shouldly;
 using Xunit;
 
 namespace DocumentDbTests.MultiTenancy;
@@ -16,7 +17,7 @@ public void get_exception_when_creating_session_with_default_tenant_usage_disabl
             _.Advanced.DefaultTenantUsageEnabled = false;
         });
 
-        Exception<DefaultTenantUsageDisabledException>.ShouldBeThrownBy(() =>
+        Should.Throw<DefaultTenantUsageDisabledException>(() =>
         {
             using (var session = theStore.LightweightSession()) { }
         });
@@ -30,7 +31,7 @@ public void get_exception_when_creating_query_session_with_default_tenant_usage_
             _.Advanced.DefaultTenantUsageEnabled = false;
         });
 
-        Exception<DefaultTenantUsageDisabledException>.ShouldBeThrownBy(() =>
+        Should.Throw<DefaultTenantUsageDisabledException>(() =>
         {
             using (var session = theStore.LightweightSession()) { }
         });
@@ -44,7 +45,7 @@ public void get_exception_when_creating_session_with_default_tenant_and_default_
             _.Advanced.DefaultTenantUsageEnabled = false;
         });
 
-        Exception<DefaultTenantUsageDisabledException>.ShouldBeThrownBy(() =>
+        Should.Throw<DefaultTenantUsageDisabledException>(() =>
         {
             using (var session = theStore.LightweightSession(Tenancy.DefaultTenantId)) { }
         });
@@ -58,7 +59,7 @@ public void get_exception_when_creating_query_session_with_default_tenant_and_de
             _.Advanced.DefaultTenantUsageEnabled = false;
         });
 
-        Exception<DefaultTenantUsageDisabledException>.ShouldBeThrownBy(() =>
+        Should.Throw<DefaultTenantUsageDisabledException>(() =>
         {
             using (var session = theStore.LightweightSession(Tenancy.DefaultTenantId)) { }
         });
@@ -72,7 +73,7 @@ public void get_exception_when_creating_session_with_default_tenant_session_opti
             _.Advanced.DefaultTenantUsageEnabled = false;
         });
 
-        Exception<DefaultTenantUsageDisabledException>.ShouldBeThrownBy(() =>
+        Should.Throw<DefaultTenantUsageDisabledException>(() =>
         {
             var sessionOptions = new SessionOptions {TenantId = Tenancy.DefaultTenantId};
             using (var session = theStore.LightweightSession(sessionOptions)) { }
@@ -87,7 +88,7 @@ public void get_exception_when_creating_query_session_with_default_tenant_sessio
             _.Advanced.DefaultTenantUsageEnabled = false;
         });
 
-        Exception<DefaultTenantUsageDisabledException>.ShouldBeThrownBy(() =>
+        Should.Throw<DefaultTenantUsageDisabledException>(() =>
         {
             var sessionOptions = new SessionOptions {TenantId = Tenancy.DefaultTenantId};
             using (var session = theStore.QuerySession(sessionOptions)) { }
diff --git a/src/DocumentDbTests/Reading/Json/streaming_json_results.cs b/src/DocumentDbTests/Reading/Json/streaming_json_results.cs
index 26a5b88c06..b23440d78b 100644
--- a/src/DocumentDbTests/Reading/Json/streaming_json_results.cs
+++ b/src/DocumentDbTests/Reading/Json/streaming_json_results.cs
@@ -337,7 +337,7 @@ public async Task first_throws_when_none_returned()
         };
         theSession.Store(user1,user2);
         await theSession.SaveChangesAsync();
-        var ex = await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () => await theSession.Query<SimpleUser>().Where(x => x.Number != 5).ToJsonFirst());
+        var ex = await Should.ThrowAsync<InvalidOperationException>(async () => await theSession.Query<SimpleUser>().Where(x => x.Number != 5).ToJsonFirst());
         ex.Message.ShouldBe("Sequence contains no elements");
     }
 
@@ -421,7 +421,7 @@ public async Task first_async_throws_when_none_returned()
         };
         theSession.Store(user1,user2);
         await theSession.SaveChangesAsync();
-        var ex = await Exception<InvalidOperationException>.ShouldBeThrownByAsync(() =>
+        var ex = await Should.ThrowAsync<InvalidOperationException>(() =>
             theSession.Query<SimpleUser>().Where(x => x.Number != 5).ToJsonFirst());
         ex.Message.ShouldBe("Sequence contains no elements");
     }
@@ -694,7 +694,7 @@ public async Task single_throws_when_none_found()
         };
         theSession.Store(user1, user2);
         await theSession.SaveChangesAsync();
-        var ex = await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () => await theSession.Query<SimpleUser>().Where(x => x.Number != 5).ToJsonSingle());
+        var ex = await Should.ThrowAsync<InvalidOperationException>(async () => await theSession.Query<SimpleUser>().Where(x => x.Number != 5).ToJsonSingle());
         ex.Message.ShouldBe("Sequence contains no elements");
     }
 
@@ -717,7 +717,7 @@ public async Task single_throws_when_more_than_one_found()
         };
         theSession.Store(user1, user2);
         await theSession.SaveChangesAsync();
-        var ex = await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () => await theSession.Query<SimpleUser>().Where(x => x.Number == 5).ToJsonSingle());
+        var ex = await Should.ThrowAsync<InvalidOperationException>(async () => await theSession.Query<SimpleUser>().Where(x => x.Number == 5).ToJsonSingle());
         ex.Message.ShouldBe("Sequence contains more than one element");
     }
 
@@ -780,7 +780,7 @@ public async Task single_async_throws_when_none_returned()
         };
         theSession.Store(user1, user2);
         await theSession.SaveChangesAsync();
-        var ex = await Exception<InvalidOperationException>.ShouldBeThrownByAsync(() =>
+        var ex = await Should.ThrowAsync<InvalidOperationException>(() =>
             theSession.Query<SimpleUser>().Where(x => x.Number != 5).ToJsonSingle());
         ex.Message.ShouldBe("Sequence contains no elements");
     }
@@ -804,7 +804,7 @@ public async Task single_async_throws_when_more_than_one_returned()
         };
         theSession.Store(user1, user2);
         await theSession.SaveChangesAsync();
-        var ex = await Exception<InvalidOperationException>.ShouldBeThrownByAsync(() =>
+        var ex = await Should.ThrowAsync<InvalidOperationException>(() =>
             theSession.Query<SimpleUser>().Where(x => x.Number == 5).ToJsonSingle());
         ex.Message.ShouldBe("Sequence contains more than one element");
     }
@@ -936,7 +936,7 @@ public async Task single_or_default_throws_when_more_than_one_found()
         };
         theSession.Store(user1, user2);
         await theSession.SaveChangesAsync();
-        var ex = await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () => await theSession.Query<SimpleUser>().Where(x => x.Number == 5).ToJsonSingleOrDefault());
+        var ex = await Should.ThrowAsync<InvalidOperationException>(async () => await theSession.Query<SimpleUser>().Where(x => x.Number == 5).ToJsonSingleOrDefault());
         ex.Message.ShouldBe("Sequence contains more than one element");
     }
 
diff --git a/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs b/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs
index bc0bdc95c5..d9061b849c 100644
--- a/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs
+++ b/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs
@@ -169,7 +169,7 @@ public void given_document_with_same_id_is_already_added_then_exception_should_o
         var session = OpenSession(tracking);
         session.Store(user1);
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() => session.Store(user2))
+        Should.Throw<InvalidOperationException>(() => session.Store(user2))
             .Message.ShouldBe("Document 'Marten.Testing.Documents.User' with same Id already added to the session.");
     }
 
diff --git a/src/DocumentDbTests/SessionMechanics/session_timeouts.cs b/src/DocumentDbTests/SessionMechanics/session_timeouts.cs
index 7b956b9e40..188440670a 100644
--- a/src/DocumentDbTests/SessionMechanics/session_timeouts.cs
+++ b/src/DocumentDbTests/SessionMechanics/session_timeouts.cs
@@ -1,6 +1,7 @@
 using System;
 using Marten.Services;
 using Marten.Testing.Harness;
+using Shouldly;
 using Xunit;
 
 namespace DocumentDbTests.SessionMechanics;
@@ -10,12 +11,12 @@ public class session_timeouts : IntegrationContext
     [Fact]
     public void should_respect_command_timeout_options()
     {
-        var ex = Exception<ArgumentOutOfRangeException>.ShouldBeThrownBy(() =>
+        var ex = Should.Throw<ArgumentOutOfRangeException>(() =>
         {
             var session = theStore.QuerySession(new SessionOptions() {Timeout = -1});
         });
 
-        ex.Message.ShouldContain("CommandTimeout can't be less than zero");
+        ex.Message.ShouldContain("CommandTimeout can't be less than zero", Case.Insensitive);
     }
 
 
@@ -23,4 +24,4 @@ public void should_respect_command_timeout_options()
     public session_timeouts(DefaultStoreFixture fixture) : base(fixture)
     {
     }
-}
\ No newline at end of file
+}
diff --git a/src/DocumentDbTests/Writing/Identity/using_string_identity.cs b/src/DocumentDbTests/Writing/Identity/using_string_identity.cs
index 642d182054..6910ab53f4 100644
--- a/src/DocumentDbTests/Writing/Identity/using_string_identity.cs
+++ b/src/DocumentDbTests/Writing/Identity/using_string_identity.cs
@@ -45,7 +45,7 @@ public void throws_exception_if_trying_to_save_null_id()
     {
         var account = new Account {Id = null};
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
             theSession.Store(account);
         });
@@ -57,7 +57,7 @@ public void throws_exception_if_trying_to_save_empty_id()
     {
         var account = new Account { Id = string.Empty };
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
             theSession.Store(account);
         });
diff --git a/src/DocumentDbTests/Writing/document_updates.cs b/src/DocumentDbTests/Writing/document_updates.cs
index 207edaf511..3701c4eaf9 100644
--- a/src/DocumentDbTests/Writing/document_updates.cs
+++ b/src/DocumentDbTests/Writing/document_updates.cs
@@ -54,7 +54,7 @@ public async Task update_sad_path_async()
         var target = Target.Random();
 
         await using var session = theStore.LightweightSession();
-        await Exception<NonExistentDocumentException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<NonExistentDocumentException>(async () =>
         {
             session.Update(target);
             await session.SaveChangesAsync();
diff --git a/src/DocumentDbTests/duplicate_document_type_alias_detection.cs b/src/DocumentDbTests/duplicate_document_type_alias_detection.cs
index a49b28453a..230ecd3c0a 100644
--- a/src/DocumentDbTests/duplicate_document_type_alias_detection.cs
+++ b/src/DocumentDbTests/duplicate_document_type_alias_detection.cs
@@ -15,7 +15,7 @@ public void throw_ambigous_alias_exception_when_you_have_duplicate_document_alia
     {
         theStore.Options.Providers.StorageFor<User>().ShouldNotBeNull();
 
-        Exception<AmbiguousDocumentTypeAliasesException>.ShouldBeThrownBy(() =>
+        Should.Throw<AmbiguousDocumentTypeAliasesException>(() =>
         {
             theStore.Options.Providers.StorageFor<User2>().ShouldNotBeNull();
         });
diff --git a/src/EventSourcingTests/Aggregation/CustomProjectionTests.cs b/src/EventSourcingTests/Aggregation/CustomProjectionTests.cs
index a83029371b..df89a781b9 100644
--- a/src/EventSourcingTests/Aggregation/CustomProjectionTests.cs
+++ b/src/EventSourcingTests/Aggregation/CustomProjectionTests.cs
@@ -120,7 +120,7 @@ public void async_options_is_not_null()
     [Fact]
     public void assert_invalid_with_no_slicer()
     {
-        Exception<InvalidProjectionException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidProjectionException>(() =>
         {
             new MyCustomAggregateWithNoSlicer().AssembleAndAssertValidity();
         });
@@ -132,7 +132,7 @@ public void assert_invalid_with_incomplete_slicing_rules()
         var projection = new MyCustomAggregateWithNoSlicer();
         projection.AggregateEvents(x => { });
 
-        Exception<InvalidProjectionException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidProjectionException>(() =>
         {
             new MyCustomAggregateWithNoSlicer().AssembleAndAssertValidity();
         });
@@ -152,7 +152,7 @@ public void throws_if_you_try_to_slice_by_string_on_something_besides_guid_or_st
     {
         var wrong = new EmptyCustomProjection<User, int>();
 
-        Exception<InvalidProjectionException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidProjectionException>(() =>
         {
             wrong.AggregateByStream();
         });
diff --git a/src/EventSourcingTests/Aggregation/fetching_async_aggregates_for_writing.cs b/src/EventSourcingTests/Aggregation/fetching_async_aggregates_for_writing.cs
index 104b4e65f6..4ba73fca58 100644
--- a/src/EventSourcingTests/Aggregation/fetching_async_aggregates_for_writing.cs
+++ b/src/EventSourcingTests/Aggregation/fetching_async_aggregates_for_writing.cs
@@ -62,7 +62,7 @@ public async Task fetch_new_stream_for_writing_Guid_identifier_exception_handlin
         await theSession.SaveChangesAsync();
 
         var sameStream = theSession.Events.StartStream(streamId, new AEvent());
-        await Exception<ExistingStreamIdCollisionException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<ExistingStreamIdCollisionException>(async () =>
         {
             await theSession.SaveChangesAsync();
         });
diff --git a/src/EventSourcingTests/Aggregation/fetching_inline_aggregates_for_writing.cs b/src/EventSourcingTests/Aggregation/fetching_inline_aggregates_for_writing.cs
index 8f6c1b158e..f63fd26204 100644
--- a/src/EventSourcingTests/Aggregation/fetching_inline_aggregates_for_writing.cs
+++ b/src/EventSourcingTests/Aggregation/fetching_inline_aggregates_for_writing.cs
@@ -111,7 +111,7 @@ public async Task fetch_new_stream_for_writing_Guid_identifier_exception_handlin
         await theSession.SaveChangesAsync();
 
         var sameStream = theSession.Events.StartStream(streamId, new AEvent());
-        await Exception<ExistingStreamIdCollisionException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<ExistingStreamIdCollisionException>(async () =>
         {
             await theSession.SaveChangesAsync();
         });
diff --git a/src/EventSourcingTests/QuickAppend/quick_append_event_capture_and_fetching_the_stream.cs b/src/EventSourcingTests/QuickAppend/quick_append_event_capture_and_fetching_the_stream.cs
index d87bdab7b1..f70fa6067a 100644
--- a/src/EventSourcingTests/QuickAppend/quick_append_event_capture_and_fetching_the_stream.cs
+++ b/src/EventSourcingTests/QuickAppend/quick_append_event_capture_and_fetching_the_stream.cs
@@ -633,7 +633,7 @@ await When.CalledForEachAsync(tenants, async (tenantId, index) =>
 
             using (var session = store.LightweightSession(tenantId))
             {
-                var streamEvents = session.Events.FetchStream(id);
+                var streamEvents = await session.Events.FetchStreamAsync(id);
 
                 streamEvents.Count.ShouldBe(1);
                 var @event = streamEvents.ElementAt(0).Data.ShouldBeOfType<ImmutableEvent>();
diff --git a/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream_Tests.cs b/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream_Tests.cs
index 68e8703b57..8469774475 100644
--- a/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream_Tests.cs
+++ b/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream_Tests.cs
@@ -649,10 +649,9 @@ public async Task capture_immutable_events(TenancyStyle tenancyStyle, string[] t
     {
         var store = InitStore(tenancyStyle);
 
-        var id = Guid.NewGuid();
-
         await When.CalledForEachAsync(tenants, async (tenantId, index) =>
         {
+            var id = Guid.NewGuid();
             var immutableEvent = new ImmutableEvent(id, "some-name");
 
             using (var session = store.LightweightSession(tenantId))
@@ -663,7 +662,7 @@ await When.CalledForEachAsync(tenants, async (tenantId, index) =>
 
             using (var session = store.LightweightSession(tenantId))
             {
-                var streamEvents = session.Events.FetchStream(id);
+                var streamEvents = await session.Events.FetchStreamAsync(id);
 
                 streamEvents.Count.ShouldBe(1);
                 var @event = streamEvents.ElementAt(0).Data.ShouldBeOfType<ImmutableEvent>();
diff --git a/src/LinqTests/Acceptance/statistics_and_paged_list.cs b/src/LinqTests/Acceptance/statistics_and_paged_list.cs
index e16461ce2d..9484bb157f 100644
--- a/src/LinqTests/Acceptance/statistics_and_paged_list.cs
+++ b/src/LinqTests/Acceptance/statistics_and_paged_list.cs
@@ -295,7 +295,7 @@ public async Task invalid_pagenumber_should_throw_exception(Func<IQueryable<Targ
         var pageSize = 10;
 
         var ex =
-            await Exception<ArgumentOutOfRangeException>.ShouldBeThrownByAsync(
+            await Should.ThrowAsync<ArgumentOutOfRangeException>(
                 async () => await toPagedList(theSession.Query<Target>(), pageNumber, pageSize));
         SpecificationExtensions.ShouldContain(ex.Message, "pageNumber = 0. PageNumber cannot be below 1.");
     }
@@ -310,7 +310,7 @@ public async Task invalid_pagesize_should_throw_exception(Func<IQueryable<Target
         var pageSize = 0;
 
         var ex =
-            await Exception<ArgumentOutOfRangeException>.ShouldBeThrownByAsync(
+            await Should.ThrowAsync<ArgumentOutOfRangeException>(
                 async () =>  await toPagedList(theSession.Query<Target>(), pageNumber, pageSize));
         SpecificationExtensions.ShouldContain(ex.Message, $"pageSize = 0. PageSize cannot be below 1.");
     }
@@ -523,7 +523,7 @@ public async Task check_query_with_where_clause_followed_by_to_pagedlist(Func<IQ
     [Fact]
     public void try_to_use_in_compiled_query()
     {
-        Exception<BadLinqExpressionException>.ShouldBeThrownBy(() =>
+        Should.Throw<BadLinqExpressionException>(() =>
         {
             var data = theSession.Query(new TargetPage(1, 10));
         });
diff --git a/src/LinqTests/Bugs/Bug_118_bad_exception_message_Tests.cs b/src/LinqTests/Bugs/Bug_118_bad_exception_message_Tests.cs
index e7832bc8c6..f7d9c9e2d0 100644
--- a/src/LinqTests/Bugs/Bug_118_bad_exception_message_Tests.cs
+++ b/src/LinqTests/Bugs/Bug_118_bad_exception_message_Tests.cs
@@ -1,6 +1,7 @@
 using System.Linq;
 using Marten.Exceptions;
 using Marten.Testing.Harness;
+using Shouldly;
 
 namespace LinqTests.Bugs;
 
@@ -16,7 +17,7 @@ public class TestClass
     [Fact]
     public void When_Property_Is_Null_Exception_Should_Be_Null_Reference_Exception()
     {
-        Exception<BadLinqExpressionException>.ShouldBeThrownBy(() =>
+        Should.Throw<BadLinqExpressionException>(() =>
         {
             theSession.Query<TestClass>().Where(x => x.Id == TestNullObject.Id).ToList();
         });
diff --git a/src/LinqTests/ChildCollections/query_against_child_collections.cs b/src/LinqTests/ChildCollections/query_against_child_collections.cs
index 15a5d16c63..076571c8a4 100644
--- a/src/LinqTests/ChildCollections/query_against_child_collections.cs
+++ b/src/LinqTests/ChildCollections/query_against_child_collections.cs
@@ -4,6 +4,7 @@
 using System.Linq.Expressions;
 using System.Threading.Tasks;
 using JasperFx.Core;
+using Marten;
 using Marten.Exceptions;
 using Marten.Linq;
 using Marten.Testing.Documents;
@@ -410,16 +411,16 @@ public void query_guid_array_intersects_array()
     }
 
     [Fact]
-    public void query_array_with_Intersect_should_blow_up()
+    public async Task query_array_with_Intersect_should_blow_up()
     {
-        buildAuthorData();
+        await buildAuthorData();
 
-        Exception<BadLinqExpressionException>.ShouldBeThrownBy(() =>
+        await Should.ThrowAsync<BadLinqExpressionException>(async () =>
         {
-            var res = theSession.Query<Article>()
+            var res = await theSession.Query<Article>()
                 .Where(x => x.AuthorArray.Any(s => favAuthors.Intersect(new Guid[] { Guid.NewGuid() }).Any()))
                 .OrderBy(x => x.Long)
-                .ToList();
+                .ToListAsync();
         });
     }
 
diff --git a/src/LinqTests/Operators/first_operator.cs b/src/LinqTests/Operators/first_operator.cs
index 42a4dae2ac..2b4ae1a369 100644
--- a/src/LinqTests/Operators/first_operator.cs
+++ b/src/LinqTests/Operators/first_operator.cs
@@ -89,7 +89,7 @@ public async Task first_miss()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
             theSession.Query<Target>().Where(x => x.Number == 11).First();
         });
@@ -199,7 +199,7 @@ public async Task first_miss_async()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<InvalidOperationException>(async () =>
         {
             await theSession.Query<Target>().Where(x => x.Number == 11).FirstAsync();
         });
diff --git a/src/LinqTests/Operators/last_operator.cs b/src/LinqTests/Operators/last_operator.cs
index 6f9de3bdbe..f0d75d7699 100644
--- a/src/LinqTests/Operators/last_operator.cs
+++ b/src/LinqTests/Operators/last_operator.cs
@@ -3,6 +3,7 @@
 using System.Threading.Tasks;
 using Marten.Testing.Documents;
 using Marten.Testing.Harness;
+using Shouldly;
 
 namespace LinqTests.Operators;
 
@@ -17,10 +18,9 @@ public async Task last_throws_an_exception()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
-            theSession.Query<Target>().Last(x => x.Number == 3)
-                .ShouldNotBeNull();
+            SpecificationExtensions.ShouldNotBeNull(theSession.Query<Target>().Last(x => x.Number == 3));
         });
     }
 
@@ -33,10 +33,9 @@ public async Task last_or_default_throws_an_exception()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
-            theSession.Query<Target>().Last(x => x.Number == 3)
-                .ShouldNotBeNull();
+            SpecificationExtensions.ShouldNotBeNull(theSession.Query<Target>().Last(x => x.Number == 3));
         });
     }
 
diff --git a/src/LinqTests/Operators/single_operator.cs b/src/LinqTests/Operators/single_operator.cs
index b315ddf28d..e141c870d3 100644
--- a/src/LinqTests/Operators/single_operator.cs
+++ b/src/LinqTests/Operators/single_operator.cs
@@ -60,7 +60,7 @@ public async Task single_hit_with_more_than_one_match()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
             theSession.Query<Target>().Where(x => x.Number == 2).Single();
         });
@@ -89,7 +89,7 @@ public async Task single_or_default_hit_with_more_than_one_match()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
             theSession.Query<Target>().Where(x => x.Number == 2).SingleOrDefault();
         });
@@ -104,7 +104,7 @@ public async Task single_miss()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        Exception<InvalidOperationException>.ShouldBeThrownBy(() =>
+        Should.Throw<InvalidOperationException>(() =>
         {
             theSession.Query<Target>().Where(x => x.Number == 11).Single();
         });
@@ -158,7 +158,7 @@ public async Task single_hit_with_more_than_one_match_async()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<InvalidOperationException>(async () =>
         {
             await theSession.Query<Target>().Where(x => x.Number == 2).SingleAsync();
         });
@@ -186,7 +186,7 @@ public async Task single_or_default_hit_with_more_than_one_match_async()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<InvalidOperationException>(async () =>
         {
             await theSession.Query<Target>().Where(x => x.Number == 2).SingleOrDefaultAsync();
         });
@@ -201,7 +201,7 @@ public async Task single_miss_async()
         theSession.Store(new Target { Number = 4 });
         await theSession.SaveChangesAsync();
 
-        await Exception<InvalidOperationException>.ShouldBeThrownByAsync(async () =>
+        await Should.ThrowAsync<InvalidOperationException>(async () =>
         {
             await theSession.Query<Target>().Where(x => x.Number == 11).SingleAsync();
         });
diff --git a/src/Marten.Testing/Harness/SpecificationExtensions.cs b/src/Marten.Testing/Harness/SpecificationExtensions.cs
index 476aea1039..870a3c1da6 100644
--- a/src/Marten.Testing/Harness/SpecificationExtensions.cs
+++ b/src/Marten.Testing/Harness/SpecificationExtensions.cs
@@ -14,48 +14,6 @@
 
 namespace Marten.Testing.Harness
 {
-
-    [Obsolete("Use Shouldly instead. Just no reason to have this any longer")]
-    public static class Exception<T> where T : Exception
-    {
-
-        public static T ShouldBeThrownBy(Action action)
-        {
-            T exception = null;
-
-            try
-            {
-                action();
-            }
-            catch (Exception e)
-            {
-                exception = e.ShouldBeOfType<T>();
-            }
-
-            exception.ShouldNotBeNull("An exception was expected, but not thrown by the given action.");
-
-            return exception;
-        }
-
-        public static async Task<T> ShouldBeThrownByAsync(Func<Task> action)
-        {
-            T exception = null;
-
-            try
-            {
-                await action();
-            }
-            catch (Exception e)
-            {
-                exception = e.ShouldBeOfType<T>();
-            }
-
-            exception.ShouldNotBeNull("An exception was expected, but not thrown by the given action.");
-
-            return exception;
-        }
-    }
-
     public delegate void MethodThatThrows();
 
     public static class SpecificationExtensions