diff --git a/src/CoreTests/Bugs/Bug_1258_cannot_derive_updates_for_objects.cs b/src/CoreTests/Bugs/Bug_1258_cannot_derive_updates_for_objects.cs index b15e602f91..2222f3cbdc 100644 --- a/src/CoreTests/Bugs/Bug_1258_cannot_derive_updates_for_objects.cs +++ b/src/CoreTests/Bugs/Bug_1258_cannot_derive_updates_for_objects.cs @@ -9,18 +9,11 @@ using Weasel.Core; using Weasel.Postgresql; using Xunit; -using Xunit.Abstractions; namespace CoreTests.Bugs; public class Bug_1258_cannot_derive_updates_for_objects: BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1258_cannot_derive_updates_for_objects(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task can_properly_detect_changes_when_user_defined_type() @@ -38,7 +31,6 @@ public async Task can_properly_detect_changes_when_user_defined_type() }); opts.Schema.For().GinIndexJsonData(); - opts.Logger(new TestOutputMartenLogger(_output)); }); var guyWithCustomType1 = new UserWithCustomType { Id = Guid.NewGuid(), Name = "test_guy", CustomType = "test_cust_type" }; diff --git a/src/CoreTests/Bugs/Bug_2914_NGram_index_being_changed_incorrectly.cs b/src/CoreTests/Bugs/Bug_2914_NGram_index_being_changed_incorrectly.cs index cdb3d34565..a0b0e957cf 100644 --- a/src/CoreTests/Bugs/Bug_2914_NGram_index_being_changed_incorrectly.cs +++ b/src/CoreTests/Bugs/Bug_2914_NGram_index_being_changed_incorrectly.cs @@ -1,26 +1,16 @@ -using System.Diagnostics; using System.Threading.Tasks; using Marten.Testing.Harness; using Xunit; -using Xunit.Abstractions; namespace CoreTests.Bugs; public class Bug_2914_NGram_index_being_changed_incorrectly : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2914_NGram_index_being_changed_incorrectly(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task recognize_when_it_is_correct() { StoreOptions(opts => { - opts.Logger(new TestOutputMartenLogger(_output)); opts.Schema.For().NgramIndex(x => x.NGramString); }); @@ -28,7 +18,6 @@ public async Task recognize_when_it_is_correct() var store = SeparateStore(opts => { - opts.Logger(new TestOutputMartenLogger(_output)); opts.Schema.For().NgramIndex(x => x.NGramString); }); diff --git a/src/CoreTests/DocumentCleanerTests.cs b/src/CoreTests/DocumentCleanerTests.cs index 9a1883865a..604728289a 100644 --- a/src/CoreTests/DocumentCleanerTests.cs +++ b/src/CoreTests/DocumentCleanerTests.cs @@ -13,20 +13,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace CoreTests; public class DocumentCleanerTests: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; private IDocumentCleaner theCleaner => theStore.Advanced.Clean; - public DocumentCleanerTests(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task clean_table() { @@ -145,8 +138,6 @@ public async Task delete_all_event_data() [Fact] public async Task delete_all_event_data_async() { - theSession.Logger = new TestOutputMartenLogger(_output); - theSession.QueueOperation(new InsertProjectionProgress(theStore.Events, new EventRange(new ShardName("Projection1", "All", 1), 1000))); diff --git a/src/DocumentDbTests/ForeignKeys/foreign_keys.cs b/src/CoreTests/ForeignKeys/foreign_keys.cs similarity index 99% rename from src/DocumentDbTests/ForeignKeys/foreign_keys.cs rename to src/CoreTests/ForeignKeys/foreign_keys.cs index 5ffae49ff7..5b7c855145 100644 --- a/src/DocumentDbTests/ForeignKeys/foreign_keys.cs +++ b/src/CoreTests/ForeignKeys/foreign_keys.cs @@ -7,7 +7,7 @@ using Weasel.Postgresql; using Xunit; -namespace DocumentDbTests.ForeignKeys; +namespace CoreTests.ForeignKeys; public class foreign_keys: OneOffConfigurationsContext { diff --git a/src/CoreTests/Partitioning/partitioning_configuration.cs b/src/CoreTests/Partitioning/partitioning_configuration.cs index 11a1c61199..bf03436231 100644 --- a/src/CoreTests/Partitioning/partitioning_configuration.cs +++ b/src/CoreTests/Partitioning/partitioning_configuration.cs @@ -11,19 +11,11 @@ using Weasel.Postgresql; using Weasel.Postgresql.Tables.Partitioning; using Xunit; -using Xunit.Abstractions; namespace CoreTests.Partitioning; public class partitioning_configuration : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public partitioning_configuration(ITestOutputHelper output) - { - _output = output; - } - private DocumentTable tableFor() { var mapping = theStore.Options.Storage.MappingFor(typeof(T)); @@ -76,7 +68,6 @@ public async Task actually_build_out_partitioned_tables() StoreOptions(opts => { opts.Schema.For().SoftDeletedWithPartitioning(); - opts.Logger(new TestOutputMartenLogger(_output)); }); await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); diff --git a/src/CoreTests/Partitioning/querying_against_conjoined_partitioning_with_tenant_id_and_subquery.cs b/src/CoreTests/Partitioning/querying_against_conjoined_partitioning_with_tenant_id_and_subquery.cs index 245f94d577..514b00eb4b 100644 --- a/src/CoreTests/Partitioning/querying_against_conjoined_partitioning_with_tenant_id_and_subquery.cs +++ b/src/CoreTests/Partitioning/querying_against_conjoined_partitioning_with_tenant_id_and_subquery.cs @@ -6,19 +6,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace CoreTests.Partitioning; public class querying_against_conjoined_partitioning_with_tenant_id_and_subquery : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public querying_against_conjoined_partitioning_with_tenant_id_and_subquery(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task do_not_bleed_tenant_data_because_of_select_queries() { @@ -39,7 +31,6 @@ public async Task do_not_bleed_tenant_data_because_of_select_queries() await theStore.BulkInsertAsync("blue", blues); using var session = theStore.LightweightSession("red"); - session.Logger = new TestOutputMartenLogger(_output); var matching = await session.Query() .Where(x => x.Children.Any(c => c.Number > 8)) diff --git a/src/CoreTests/bootstrapping_with_service_collection_extensions.cs b/src/CoreTests/bootstrapping_with_service_collection_extensions.cs index c73e16d866..b55616e160 100644 --- a/src/CoreTests/bootstrapping_with_service_collection_extensions.cs +++ b/src/CoreTests/bootstrapping_with_service_collection_extensions.cs @@ -91,13 +91,13 @@ public void add_marten_by_store_options_with_custom_logger() { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); - options.Logger(new TestOutputMartenLogger(null)); + options.Logger(new ConsoleMartenLogger()); return options; }); }); var store = container.GetRequiredService(); - store.Options.Logger().ShouldBeOfType(); + store.Options.Logger().ShouldBeOfType(); } [Fact] diff --git a/src/DocumentDbTests/Bugs/Bug_1416_foreign_key_with_document_alias.cs b/src/DocumentDbTests/Bugs/Bug_1416_foreign_key_with_document_alias.cs index becd83fb80..20a64bc7d4 100644 --- a/src/DocumentDbTests/Bugs/Bug_1416_foreign_key_with_document_alias.cs +++ b/src/DocumentDbTests/Bugs/Bug_1416_foreign_key_with_document_alias.cs @@ -3,18 +3,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Bugs; public class Bug_1416_foreign_key_with_document_alias : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1416_foreign_key_with_document_alias(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task use_the_correct_naming() diff --git a/src/DocumentDbTests/Bugs/Bug_1429_fk_ordering_problems.cs b/src/DocumentDbTests/Bugs/Bug_1429_fk_ordering_problems.cs index e7f9498f6c..edfabaaa35 100644 --- a/src/DocumentDbTests/Bugs/Bug_1429_fk_ordering_problems.cs +++ b/src/DocumentDbTests/Bugs/Bug_1429_fk_ordering_problems.cs @@ -5,25 +5,17 @@ using Weasel.Core; using Weasel.Postgresql; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Bugs; public class Bug_1429_fk_ordering_problems : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public Bug_1429_fk_ordering_problems(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task try_to_persist() { StoreOptions(_ => { - _.Logger(new TestOutputMartenLogger(_output)); _.AutoCreateSchemaObjects = AutoCreate.All; _.Schema.For() .AddSubClassHierarchy(typeof(DocB1), typeof(DocB2)) diff --git a/src/DocumentDbTests/Bugs/Bug_1779_null_comparison_to_foreign_key_column_not_generating_is_null.cs b/src/DocumentDbTests/Bugs/Bug_1779_null_comparison_to_foreign_key_column_not_generating_is_null.cs index a1348c16d2..619de2bf97 100644 --- a/src/DocumentDbTests/Bugs/Bug_1779_null_comparison_to_foreign_key_column_not_generating_is_null.cs +++ b/src/DocumentDbTests/Bugs/Bug_1779_null_comparison_to_foreign_key_column_not_generating_is_null.cs @@ -10,18 +10,11 @@ using Weasel.Core; using Weasel.Postgresql; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Bugs { public class Bug_1779_null_comparison_to_foreign_key_column_not_generating_is_null : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1779_null_comparison_to_foreign_key_column_not_generating_is_null(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task should_be_able_to_filter_with_null_value() @@ -41,7 +34,6 @@ public async Task should_be_able_to_filter_with_null_value() await session.SaveChangesAsync(); await using var querySession = documentStore.QuerySession(); - querySession.Logger = new TestOutputMartenLogger(_output); var results = await querySession.Query() .Where(x => x.Name == "Test" && x.ParentId == null) @@ -70,7 +62,6 @@ public async Task should_be_able_to_filter_with_null_value_and_not_equals() await session.SaveChangesAsync(); await using var querySession = documentStore.QuerySession(); - querySession.Logger = new TestOutputMartenLogger(_output); var results = await querySession.Query() .Where(x => x.Name == "Test" && x.ParentId != null) diff --git a/src/DocumentDbTests/Bugs/Bug_1871_includes_with_snake_case_json.cs b/src/DocumentDbTests/Bugs/Bug_1871_includes_with_snake_case_json.cs index 09248e69d4..043f04f4df 100644 --- a/src/DocumentDbTests/Bugs/Bug_1871_includes_with_snake_case_json.cs +++ b/src/DocumentDbTests/Bugs/Bug_1871_includes_with_snake_case_json.cs @@ -6,18 +6,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Bugs; public class Bug_1871_includes_with_snake_case_json : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1871_includes_with_snake_case_json(ITestOutputHelper output) - { - _output = output; - } public class Role { @@ -46,7 +39,6 @@ public async Task includes_should_work() StoreOptions(opts => { opts.UseSystemTextJsonForSerialization(casing: Casing.SnakeCase); - opts.Logger(new TestOutputMartenLogger(_output)); }); var admin = new Role {Name = "Admin"}; diff --git a/src/DocumentDbTests/Bugs/Bug_1975_bulk_insert_of_nested_guid.cs b/src/DocumentDbTests/Bugs/Bug_1975_bulk_insert_of_nested_guid.cs index f840a9e113..2e289071e6 100644 --- a/src/DocumentDbTests/Bugs/Bug_1975_bulk_insert_of_nested_guid.cs +++ b/src/DocumentDbTests/Bugs/Bug_1975_bulk_insert_of_nested_guid.cs @@ -3,18 +3,11 @@ using System.Threading.Tasks; using Marten.Testing.Harness; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Bugs; public class Bug_1975_bulk_insert_of_nested_guid : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1975_bulk_insert_of_nested_guid(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task can_bulk_insert() diff --git a/src/DocumentDbTests/Bugs/Bug_1994_insert_update_on_same_object_in_transaction.cs b/src/DocumentDbTests/Bugs/Bug_1994_insert_update_on_same_object_in_transaction.cs index 28cb7cf8b1..33f85282cb 100644 --- a/src/DocumentDbTests/Bugs/Bug_1994_insert_update_on_same_object_in_transaction.cs +++ b/src/DocumentDbTests/Bugs/Bug_1994_insert_update_on_same_object_in_transaction.cs @@ -6,18 +6,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Bugs; public class Bug_1994_insert_update_on_same_object_in_transaction: BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1994_insert_update_on_same_object_in_transaction(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task bug_1994_pending_changes_after_insert_and_store_on_same_object() @@ -27,8 +20,6 @@ public async Task bug_1994_pending_changes_after_insert_and_store_on_same_object var user1 = new User(); await using var session1 = theStore.LightweightSession(); - session1.Logger = new TestOutputMartenLogger(_output); - session1.Insert(user1); diff --git a/src/DocumentDbTests/Bugs/Bug_3378_jsonb_ops_index_syntax.cs b/src/DocumentDbTests/Bugs/Bug_3378_jsonb_ops_index_syntax.cs index b9ed53c04e..75c3bb4121 100644 --- a/src/DocumentDbTests/Bugs/Bug_3378_jsonb_ops_index_syntax.cs +++ b/src/DocumentDbTests/Bugs/Bug_3378_jsonb_ops_index_syntax.cs @@ -8,18 +8,11 @@ using Marten.Storage; using Marten.Testing.Harness; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Bugs; public class Bug_3378_jsonb_ops_index_syntax : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3378_jsonb_ops_index_syntax(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task use_same_syntax_as_query() @@ -27,7 +20,6 @@ public async Task use_same_syntax_as_query() StoreOptions(opts => { opts.Schema.For().Index(x => x.ChildCollection, index => index.ToGinWithJsonbPathOps()); - opts.Logger(new TestOutputMartenLogger(_output)); }); await theStore.Storage.Database.EnsureStorageExistsAsync(typeof(SomeModel)); diff --git a/src/DocumentDbTests/Concurrency/numeric_revisioning.cs b/src/DocumentDbTests/Concurrency/numeric_revisioning.cs index a39b6fd2b7..f7a074894d 100644 --- a/src/DocumentDbTests/Concurrency/numeric_revisioning.cs +++ b/src/DocumentDbTests/Concurrency/numeric_revisioning.cs @@ -13,19 +13,12 @@ using Shouldly; using Weasel.Core; using Xunit; -using Xunit.Abstractions; using IRevisioned = Marten.Metadata.IRevisioned; namespace DocumentDbTests.Concurrency; public class numeric_revisioning: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public numeric_revisioning(ITestOutputHelper output) - { - _output = output; - } [Fact] public void use_numeric_revisions_is_off_by_default() @@ -156,7 +149,7 @@ public async Task store_twice_with_no_version_can_override() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Store(new RevisionedDoc{Id = doc1.Id, Name = "Brad"}); await theSession.SaveChangesAsync(); @@ -183,7 +176,7 @@ public async Task optimistic_concurrency_failure_with_update_revision() theSession.UpdateRevision(doc2, doc1.Version + 1); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + await Should.ThrowAsync(async () => { @@ -235,7 +228,7 @@ public async Task update_just_overwrites_and_increments_version() theSession.Store(doc1); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var doc2 = new RevisionedDoc { Id = doc1.Id, Name = "Wrong", Version = 0}; theSession.UpdateRevision(doc2, doc1.Version + 1); @@ -307,8 +300,6 @@ public async Task overwrite_increments_version() doc2.Version = 0; session2.Store(doc2); - session2.Logger = new TestOutputMartenLogger(_output); - await session2.SaveChangesAsync(); var doc3 = await session2.LoadAsync(doc1.Id); @@ -351,7 +342,7 @@ public async Task load_and_update_revisioned_document_by_revision_from_identity_ doc2.Name = "Different"; session.UpdateRevision(doc2, 2); - session.Logger = new TestOutputMartenLogger(_output); + await session.SaveChangesAsync(); } @@ -416,7 +407,7 @@ public async Task optimistic_concurrency_failure_with_update_revision_when_revis theSession.UpdateRevision(doc2, doc1.Version + 1); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + await Should.ThrowAsync(async () => { @@ -445,7 +436,7 @@ public async Task optimistic_concurrency_failure_with_update_revision_when_revis theSession.UpdateRevision(doc2, doc1.Version + 1); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + await Should.ThrowAsync(async () => { diff --git a/src/DocumentDbTests/Configuration/document_policies.cs b/src/DocumentDbTests/Configuration/document_policies.cs index 53f1f898e1..c276b385b7 100644 --- a/src/DocumentDbTests/Configuration/document_policies.cs +++ b/src/DocumentDbTests/Configuration/document_policies.cs @@ -5,18 +5,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Configuration; public class document_policies: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public document_policies(ITestOutputHelper output) + public document_policies() { - _output = output; - StoreOptions(_ => { _.Schema.For(); diff --git a/src/DocumentDbTests/Deleting/delete_many_documents_by_query.cs b/src/DocumentDbTests/Deleting/delete_many_documents_by_query.cs index 0f83c4db0e..22bc540353 100644 --- a/src/DocumentDbTests/Deleting/delete_many_documents_by_query.cs +++ b/src/DocumentDbTests/Deleting/delete_many_documents_by_query.cs @@ -6,14 +6,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Deleting; public class delete_many_documents_by_query : IntegrationContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task can_delete_by_query() { @@ -43,8 +40,6 @@ public async Task can_delete_by_query() [Fact] public async Task delete_where_with_sub_collection_querying() { - StoreOptions(opts => opts.Logger(new TestOutputMartenLogger(_output))); - await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Target)); var targets = Target.GenerateRandomData(50).ToArray(); @@ -89,6 +84,7 @@ public async Task can_delete_by_query_with_complex_where_clauses() [Fact] public async Task in_a_mix_with_other_commands() { + await theStore.Advanced.ResetAllData(); var targets = Target.GenerateRandomData(50).ToArray(); for (var i = 0; i < 15; i++) { @@ -134,8 +130,7 @@ public async Task can_delete_by_query_multiple() } - public delete_many_documents_by_query(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public delete_many_documents_by_query(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/DocumentDbTests/Deleting/soft_deletes.cs b/src/DocumentDbTests/Deleting/soft_deletes.cs index 2b6494d83c..f5b10f9210 100644 --- a/src/DocumentDbTests/Deleting/soft_deletes.cs +++ b/src/DocumentDbTests/Deleting/soft_deletes.cs @@ -17,7 +17,6 @@ using Weasel.Postgresql; using Weasel.Postgresql.Tables.Partitioning; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Deleting; @@ -52,12 +51,8 @@ public class SoftDeletedDocument: ISoftDeleted public class soft_deletes: StoreContext, IClassFixture, IAsyncLifetime { - private readonly ITestOutputHelper _output; - - public soft_deletes(SoftDeletedFixture fixture, ITestOutputHelper output): base(fixture) + public soft_deletes(SoftDeletedFixture fixture): base(fixture) { - _output = output; - } public async Task InitializeAsync() @@ -85,8 +80,6 @@ public async Task can_query_by_the_deleted_column_if_it_exists() await using var session2 = theStore.LightweightSession(); - session2.Logger = new TestOutputMartenLogger(_output); - session2.Delete(doc1); session2.Delete(doc3); await session2.SaveChangesAsync(); @@ -270,8 +263,6 @@ public async Task un_delete_a_document_by_where_row_state() var user3 = new User { UserName = "baz" }; using var session = theStore.LightweightSession(); - session.Logger = new TestOutputMartenLogger(_output); - session.Store(user1, user2, user3); await session.SaveChangesAsync(); @@ -742,8 +733,6 @@ public async Task delete_sets_ISoftDeleted_properties_on_in_memory_document() public class soft_deletes_with_partitioning: OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; - public soft_deletes_with_partitioning() { StoreOptions(opts => @@ -793,8 +782,6 @@ public async Task can_query_by_the_deleted_column_if_it_exists() await using var session2 = theStore.LightweightSession(); - session2.Logger = new TestOutputMartenLogger(_output); - session2.Delete(doc1); session2.Delete(doc3); await session2.SaveChangesAsync(); @@ -978,8 +965,6 @@ public async Task un_delete_a_document_by_where_row_state() var user3 = new User { UserName = "baz" }; using var session = theStore.LightweightSession(); - session.Logger = new TestOutputMartenLogger(_output); - session.Store(user1, user2, user3); await session.SaveChangesAsync(); diff --git a/src/DocumentDbTests/HierarchicalStorage/Bug_1247_end_to_end_query_with_include_and_document_hierarchy_Tests.cs b/src/DocumentDbTests/HierarchicalStorage/Bug_1247_end_to_end_query_with_include_and_document_hierarchy_Tests.cs index bbf621f339..0c13fbb883 100644 --- a/src/DocumentDbTests/HierarchicalStorage/Bug_1247_end_to_end_query_with_include_and_document_hierarchy_Tests.cs +++ b/src/DocumentDbTests/HierarchicalStorage/Bug_1247_end_to_end_query_with_include_and_document_hierarchy_Tests.cs @@ -6,18 +6,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.HierarchicalStorage; public class Bug_1247_query_with_include_and_document_hierarchy_Tests: end_to_end_document_hierarchy_usage_Tests { - private new readonly ITestOutputHelper _output; - - public Bug_1247_query_with_include_and_document_hierarchy_Tests(ITestOutputHelper output) - { - _output = output; - } // [Fact] flaky in CI public async Task include_to_list_using_outer_join() @@ -36,8 +29,6 @@ public async Task include_to_list_using_outer_join() await session.SaveChangesAsync(); using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); - var list = new List(); var issues = query.Query().Include(x => x.AssigneeId, list).ToArray(); diff --git a/src/DocumentDbTests/Indexes/duplicated_field.cs b/src/DocumentDbTests/Indexes/duplicated_field.cs index a1939aaa3b..3e95ffd08c 100644 --- a/src/DocumentDbTests/Indexes/duplicated_field.cs +++ b/src/DocumentDbTests/Indexes/duplicated_field.cs @@ -15,18 +15,11 @@ using Weasel.Core; using Weasel.Postgresql.Tables; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Indexes; public class duplicated_field: OneOffConfigurationsContext { - private readonly ITestOutputHelper _testOutputHelper; - - public duplicated_field(ITestOutputHelper testOutputHelper) - { - _testOutputHelper = testOutputHelper; - } [Fact] public async Task can_insert_document_with_duplicated_field_with_DuplicatedFieldEnumStorage_set_to_string() @@ -265,7 +258,6 @@ public async Task duplicate_and_search_off_of_deep_accessor_by_date() .Any(x => x.Id == thirdTarget.Id).ShouldBeTrue(); var text = queryable.ToCommand(FetchType.FetchMany).CommandText; - _testOutputHelper.WriteLine(text); text.ShouldContain("inner_date = :p0", Case.Insensitive); } diff --git a/src/DocumentDbTests/Metadata/last_modified_queries.cs b/src/DocumentDbTests/Metadata/last_modified_queries.cs index 44c47a375c..5752cae837 100644 --- a/src/DocumentDbTests/Metadata/last_modified_queries.cs +++ b/src/DocumentDbTests/Metadata/last_modified_queries.cs @@ -84,6 +84,7 @@ public async Task query_modified_since_docs() [Fact] public async Task query_modified_before_docs() { + await theStore.Advanced.ResetAllData(); var user1 = new User { UserName = "foo" }; var user2 = new User { UserName = "bar" }; var user3 = new User { UserName = "baz" }; diff --git a/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy.cs b/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy.cs index 7b8ea7a95a..669b6f845e 100644 --- a/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy.cs +++ b/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy.cs @@ -13,7 +13,6 @@ using Weasel.Core; using Weasel.Postgresql.Tables; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.MultiTenancy; @@ -28,7 +27,6 @@ public static async Task delete_all_tenant_data(IDocumentStore store, Cancellati #endregion - private readonly ITestOutputHelper _output; private readonly Target[] _greens = Target.GenerateRandomData(100).ToArray(); private readonly Target[] _reds = Target.GenerateRandomData(100).ToArray(); @@ -620,14 +618,12 @@ public async Task can_delete_a_document_by_id_and_tenant_Guid() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } var blue = theStore.QuerySession("Blue"); - blue.Logger = new TestOutputMartenLogger(_output); - (await blue.LoadAsync(target.Id)).ShouldBeNull(); var red = theStore.QuerySession("Red"); @@ -654,7 +650,7 @@ public async Task can_delete_a_document_by_id_and_tenant_int() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } @@ -685,7 +681,7 @@ public async Task can_delete_a_document_by_id_and_tenant_long() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } @@ -716,7 +712,7 @@ public async Task can_delete_a_document_by_id_and_tenant_string() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } diff --git a/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy_with_partitioning.cs b/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy_with_partitioning.cs index 6bb12d8047..f5e02fbda4 100644 --- a/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy_with_partitioning.cs +++ b/src/DocumentDbTests/MultiTenancy/conjoined_multi_tenancy_with_partitioning.cs @@ -12,13 +12,11 @@ using Weasel.Core; using Weasel.Postgresql.Tables; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.MultiTenancy; public class conjoined_multi_tenancy_with_partitioning: OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; private readonly Target[] _greens = Target.GenerateRandomData(100).ToArray(); private readonly Target[] _reds = Target.GenerateRandomData(100).ToArray(); @@ -623,14 +621,12 @@ public async Task can_delete_a_document_by_id_and_tenant_Guid() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } var blue = theStore.QuerySession("Blue"); - blue.Logger = new TestOutputMartenLogger(_output); - (await blue.LoadAsync(target.Id)).ShouldBeNull(); var red = theStore.QuerySession("Red"); @@ -657,7 +653,7 @@ public async Task can_delete_a_document_by_id_and_tenant_int() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } @@ -688,7 +684,7 @@ public async Task can_delete_a_document_by_id_and_tenant_long() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } @@ -719,7 +715,7 @@ public async Task can_delete_a_document_by_id_and_tenant_string() await using (var session = theStore.LightweightSession()) { - session.Logger = new TestOutputMartenLogger(_output); + session.ForTenant("Blue").Delete(target.Id); await session.SaveChangesAsync(); } diff --git a/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_acceptance_Tests.cs b/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_acceptance_Tests.cs index 5b6a45b20f..4a5803a12e 100644 --- a/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_acceptance_Tests.cs +++ b/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_acceptance_Tests.cs @@ -10,13 +10,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Reading.BatchedQuerying; public class batched_querying_acceptance_Tests: OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; private readonly Target target1 = Target.Random(); private readonly Target target2 = Target.Random(); private readonly Target target3 = Target.Random(); @@ -43,10 +41,8 @@ public class batched_querying_acceptance_Tests: OneOffConfigurationsContext, IAs UserName = "B3", FirstName = "Sean", LastName = "Smith", Role = "Master" }; - public batched_querying_acceptance_Tests(ITestOutputHelper output) + public batched_querying_acceptance_Tests() { - _output = output; - } public async Task InitializeAsync() @@ -361,7 +357,6 @@ public async Task can_find_docs_by_id_that_should_be_in_identity_map() public async Task can_find_multiple_docs_by_id() { await using var session = theStore.IdentitySession(); - session.Logger = new TestOutputMartenLogger(_output); var batch1 = session.CreateBatchQuery(); var task = batch1.LoadMany().ById(target1.Id, target3.Id); diff --git a/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_aggregate_functions.cs b/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_aggregate_functions.cs index a7b57d70b8..8a39c58c70 100644 --- a/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_aggregate_functions.cs +++ b/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_aggregate_functions.cs @@ -31,6 +31,11 @@ public async Task can_run_aggregate_functions() (await average).ShouldBe(3.75); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public batched_querying_with_aggregate_functions(DefaultStoreFixture fixture): base(fixture) { } diff --git a/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_order_functions.cs b/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_order_functions.cs index c0cf832344..79d9707c58 100644 --- a/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_order_functions.cs +++ b/src/DocumentDbTests/Reading/BatchedQuerying/batched_querying_with_order_functions.cs @@ -64,8 +64,9 @@ public async Task orderbydescending_thenbydescending() names.Select(x => x.LastName).ShouldHaveTheSameElementsAs("Brown", "Bean", "White", "Houston", "Somerset", "Smith"); } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); theSession.Store( new User { FirstName = "Justin", LastName = "Houston" }, new User { FirstName = "Justin", LastName = "White" }, @@ -75,7 +76,7 @@ protected override Task fixtureSetup() new User { FirstName = "Harry", LastName = "Somerset" } ); - return theSession.SaveChangesAsync(); + await theSession.SaveChangesAsync(); } public batched_querying_with_order_functions(DefaultStoreFixture fixture) : base(fixture) diff --git a/src/DocumentDbTests/Reading/Json/get_raw_json_Tests.cs b/src/DocumentDbTests/Reading/Json/get_raw_json_Tests.cs index d42733ac83..17f42afb4c 100644 --- a/src/DocumentDbTests/Reading/Json/get_raw_json_Tests.cs +++ b/src/DocumentDbTests/Reading/Json/get_raw_json_Tests.cs @@ -32,6 +32,7 @@ public async Task when_get_json_then_raw_json_should_be_returned() [Fact] public async Task when_get_json_then_raw_json_should_be_returned_async() { + await theStore.Advanced.ResetAllData(); var issue = new Issue { Title = "Issue 1" }; theSession.Store(issue); diff --git a/src/DocumentDbTests/Reading/Json/streaming_json_results.cs b/src/DocumentDbTests/Reading/Json/streaming_json_results.cs index ca1726135a..f03a09dd3e 100644 --- a/src/DocumentDbTests/Reading/Json/streaming_json_results.cs +++ b/src/DocumentDbTests/Reading/Json/streaming_json_results.cs @@ -52,6 +52,11 @@ public streaming_json_results(DefaultStoreFixture fixture) : base(fixture) { } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + private T deserialize(Stream stream) { stream.Position = 0; diff --git a/src/DocumentDbTests/Reading/advanced_sql_query.cs b/src/DocumentDbTests/Reading/advanced_sql_query.cs index 317b76af85..b0f99d3af3 100644 --- a/src/DocumentDbTests/Reading/advanced_sql_query.cs +++ b/src/DocumentDbTests/Reading/advanced_sql_query.cs @@ -80,6 +80,7 @@ public async Task can_query_documents() [Fact] public async Task can_query_documents_and_will_set_metadata_on_result_documents() { + await theStore.Advanced.ResetAllData(); await using var session = theStore.LightweightSession(); session.Store(new DocWithMeta { Id = 1, Name = "Max" }); await session.SaveChangesAsync(); @@ -97,6 +98,7 @@ public async Task can_query_documents_and_will_set_metadata_on_result_documents( [Fact] public async Task can_query_multiple_documents_and_scalar() { + await theStore.Advanced.ResetAllData(); await using var session = theStore.LightweightSession(); #region sample_advanced_sql_query_related_documents_and_scalar session.Store(new DocWithMeta { Id = 1, Name = "Max" }); @@ -141,6 +143,7 @@ limit 2 [Fact] public async Task can_query_with_parameters() { + await theStore.Advanced.ResetAllData(); await using var session = theStore.LightweightSession(); session.Store(new DocWithMeta { Id = 1, Name = "Max" }); await session.SaveChangesAsync(); @@ -169,6 +172,7 @@ public async Task can_query_with_parameters() [Fact] public async Task can_async_stream_multiple_documents_and_scalar() { + await theStore.Advanced.ResetAllData(); await using var session = theStore.LightweightSession(); #region sample_advanced_sql_stream_related_documents_and_scalar session.Store(new DocWithMeta { Id = 1, Name = "Max" }); diff --git a/src/DocumentDbTests/Reading/query_by_sql.cs b/src/DocumentDbTests/Reading/query_by_sql.cs index 13f50b5e97..18585ad4e9 100644 --- a/src/DocumentDbTests/Reading/query_by_sql.cs +++ b/src/DocumentDbTests/Reading/query_by_sql.cs @@ -9,17 +9,18 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.Reading; public class query_by_sql: IntegrationContext { - private readonly ITestOutputHelper _output; + public query_by_sql(DefaultStoreFixture fixture): base(fixture) + { + } - public query_by_sql(DefaultStoreFixture fixture, ITestOutputHelper output): base(fixture) + protected override async Task fixtureSetup() { - _output = output; + await theStore.Advanced.ResetAllData(); } [Fact] diff --git a/src/DocumentDbTests/SessionMechanics/Using_Global_DocumentSessionListener_Tests.cs b/src/DocumentDbTests/SessionMechanics/Using_Global_DocumentSessionListener_Tests.cs index 9ced3ec8c4..7a0507b349 100644 --- a/src/DocumentDbTests/SessionMechanics/Using_Global_DocumentSessionListener_Tests.cs +++ b/src/DocumentDbTests/SessionMechanics/Using_Global_DocumentSessionListener_Tests.cs @@ -4,18 +4,25 @@ using JasperFx; using Marten.Testing.Documents; using Marten.Testing.Harness; +using Npgsql; using Shouldly; using Weasel.Core; using Xunit; namespace DocumentDbTests.SessionMechanics; -public class Using_Global_DocumentSessionListener_Tests : OneOffConfigurationsContext +public class Using_Global_DocumentSessionListener_Tests : OneOffConfigurationsContext, IAsyncLifetime { - public Using_Global_DocumentSessionListener_Tests() + public async Task InitializeAsync() { + await using var conn = new NpgsqlConnection(ConnectionSource.ConnectionString); + await conn.OpenAsync(); + await conn.CreateCommand($"drop schema if exists {SchemaName} cascade") + .ExecuteNonQueryAsync(); } + public Task DisposeAsync() => Task.CompletedTask; + [Fact] public async Task call_listener_events_on_synchronous_session_saves() { @@ -33,8 +40,6 @@ public async Task call_listener_events_on_synchronous_session_saves() })) #endregion { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); - using (var session = store.LightweightSession()) { session.Store(new User(), new User()); @@ -65,8 +70,6 @@ public async Task call_listener_events_on_synchronous_session_saves_async() _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); - await using (var session = store.LightweightSession()) { session.Store(new User(), new User()); @@ -97,8 +100,6 @@ public async Task call_listener_events_on_document_store() _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); - using (var session = store.LightweightSession()) { var user1 = new User { Id = Guid.NewGuid() }; @@ -130,8 +131,6 @@ public async Task call_listener_events_on_document_store_objects() _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); - using (var session = store.LightweightSession()) { var user1 = new User { Id = Guid.NewGuid() }; @@ -163,7 +162,6 @@ public async Task call_listener_events_on_document_load() _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; @@ -199,7 +197,6 @@ public async Task call_listener_events_on_document_query() _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; @@ -238,7 +235,6 @@ public async Task call_listener_events_on_document_store_and_dirty_tracking_sess _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); using (var session = store.DirtyTrackedSession()) { @@ -271,7 +267,6 @@ public async Task call_listener_events_on_document_store_objects_and_dirty_track _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); using (var session = store.DirtyTrackedSession()) { @@ -304,7 +299,6 @@ public async Task call_listener_events_on_document_load_and_dirty_tracking_sessi _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; @@ -340,7 +334,6 @@ public async Task call_listener_events_on_document_query_and_dirty_tracking_sess _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; @@ -379,7 +372,6 @@ public async Task call_listener_events_on_document_load_with_lightweightsession( _.Listeners.Add(stub2); })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; diff --git a/src/DocumentDbTests/SessionMechanics/Using_Local_DocumentSessionListener_Tests.cs b/src/DocumentDbTests/SessionMechanics/Using_Local_DocumentSessionListener_Tests.cs index 727191d447..7d6ed92cd6 100644 --- a/src/DocumentDbTests/SessionMechanics/Using_Local_DocumentSessionListener_Tests.cs +++ b/src/DocumentDbTests/SessionMechanics/Using_Local_DocumentSessionListener_Tests.cs @@ -6,14 +6,24 @@ using Marten.Services; using Marten.Testing.Documents; using Marten.Testing.Harness; +using Npgsql; using Shouldly; using Weasel.Core; using Xunit; namespace DocumentDbTests.SessionMechanics; -public class Using_Local_DocumentSessionListener_Tests: OneOffConfigurationsContext +public class Using_Local_DocumentSessionListener_Tests: OneOffConfigurationsContext, IAsyncLifetime { + public async Task InitializeAsync() + { + await using var conn = new NpgsqlConnection(ConnectionSource.ConnectionString); + await conn.OpenAsync(); + await conn.CreateCommand($"drop schema if exists {SchemaName} cascade") + .ExecuteNonQueryAsync(); + } + + public Task DisposeAsync() => Task.CompletedTask; [Fact] public async Task call_listener_events_on_synchronous_session_saves() { @@ -31,7 +41,6 @@ public async Task call_listener_events_on_synchronous_session_saves() #endregion { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); using (var session = store.LightweightSession(new SessionOptions { Listeners = { stub1, stub2 } })) { @@ -89,7 +98,6 @@ public async Task call_listener_events_on_document_store() _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); using (var session = store.LightweightSession(new SessionOptions { Listeners = { stub1, stub2 } })) { @@ -119,7 +127,6 @@ public async Task call_listener_events_on_document_store_objects() _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); using (var session = store.LightweightSession(new SessionOptions { Listeners = { stub1, stub2 } })) { @@ -149,7 +156,6 @@ public async Task call_listener_events_on_document_load() _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; @@ -182,7 +188,6 @@ public async Task call_listener_events_on_document_query() _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; @@ -222,7 +227,6 @@ public async Task call_listener_events_on_document_store_and_dirty_tracking_sess _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); using (var session = store.DirtyTrackedSession(new SessionOptions { Listeners = { stub1, stub2 } })) { @@ -252,7 +256,6 @@ public async Task call_listener_events_on_document_store_objects_and_dirty_track _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); using (var session = store.DirtyTrackedSession(new SessionOptions { Listeners = { stub1, stub2 } })) { @@ -282,7 +285,6 @@ public async Task call_listener_events_on_document_load_and_dirty_tracking_sessi _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; @@ -315,7 +317,6 @@ public async Task call_listener_events_on_document_query_and_dirty_tracking_sess _.AutoCreateSchemaObjects = AutoCreate.All; })) { - await store.Advanced.Clean.CompletelyRemoveAllAsync(); var user1 = new User { Id = Guid.NewGuid() }; var user2 = new User { Id = Guid.NewGuid() }; diff --git a/src/DocumentDbTests/SessionMechanics/ejecting_documents.cs b/src/DocumentDbTests/SessionMechanics/ejecting_documents.cs index d0aa55d81e..004713d7a5 100644 --- a/src/DocumentDbTests/SessionMechanics/ejecting_documents.cs +++ b/src/DocumentDbTests/SessionMechanics/ejecting_documents.cs @@ -411,4 +411,9 @@ public async Task eject_a_document_type_clears_updates_from_the_unit_of_work_lig public ejecting_documents(DefaultStoreFixture fixture) : base(fixture) { } + + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } } diff --git a/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs b/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs index f83b751990..988b381e4d 100644 --- a/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs +++ b/src/DocumentDbTests/SessionMechanics/identity_map_mechanics.cs @@ -80,6 +80,7 @@ public async Task when_querying_and_modifying_multiple_documents_should_track_an [Fact] public async Task when_querying_and_modifying_multiple_documents_should_track_and_persist_dirty() { + await theStore.Advanced.ResetAllData(); var user1 = new User { FirstName = "James", LastName = "Worthy 1" }; var user2 = new User { FirstName = "James", LastName = "Worthy 2" }; var user3 = new User { FirstName = "James", LastName = "Worthy 3" }; diff --git a/src/DocumentDbTests/SessionMechanics/reset_all_data_usage.cs b/src/DocumentDbTests/SessionMechanics/reset_all_data_usage.cs index d1b0efa2ea..e1a1566587 100644 --- a/src/DocumentDbTests/SessionMechanics/reset_all_data_usage.cs +++ b/src/DocumentDbTests/SessionMechanics/reset_all_data_usage.cs @@ -7,18 +7,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace DocumentDbTests.SessionMechanics; public class reset_all_data_usage : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public reset_all_data_usage(ITestOutputHelper output) - { - _output = output; - } public class Users : IInitialData { @@ -37,11 +30,6 @@ public Task Populate(IDocumentStore store, CancellationToken cancellation) [Fact] public async Task reset_clears_and_sets_the_baseline() { - StoreOptions(opts => - { - opts.Logger(new TestOutputMartenLogger(_output)); - }); - #region sample_reset_all_data theStore.Advanced.InitialDataCollection.Add(new Users()); diff --git a/src/DocumentDbTests/Writing/document_inserts.cs b/src/DocumentDbTests/Writing/document_inserts.cs index b4ac23d2b3..6319f4bfaf 100644 --- a/src/DocumentDbTests/Writing/document_inserts.cs +++ b/src/DocumentDbTests/Writing/document_inserts.cs @@ -14,6 +14,7 @@ public class document_inserts: IntegrationContext [Fact] public async Task can_insert_all_new_documents() { + await theStore.Advanced.ResetAllData(); using (var session = theStore.LightweightSession()) { session.Insert(Target.GenerateRandomData(99).ToArray()); @@ -29,6 +30,7 @@ public async Task can_insert_all_new_documents() [Fact] public async Task can_insert_a_mixed_bag_of_documents() { + await theStore.Advanced.ResetAllData(); var docs = new object[] { Target.Random(), Target.Random(), Target.Random(), new User(), new User(), new User(), new User() diff --git a/src/EventSourcingTests/Aggregation/explicit_code_for_aggregation_logic.cs b/src/EventSourcingTests/Aggregation/explicit_code_for_aggregation_logic.cs index 200a6b56dd..8ecdd06357 100644 --- a/src/EventSourcingTests/Aggregation/explicit_code_for_aggregation_logic.cs +++ b/src/EventSourcingTests/Aggregation/explicit_code_for_aggregation_logic.cs @@ -16,19 +16,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Aggregation; public class using_explicit_code_for_aggregations { - private readonly ITestOutputHelper _output; - - public using_explicit_code_for_aggregations(ITestOutputHelper output) - { - _output = output; - } - [Theory] [InlineData(true, EventAppendMode.Quick, ProjectionLifecycle.Inline, true)] [InlineData(true, EventAppendMode.Quick, ProjectionLifecycle.Async, true)] @@ -87,13 +79,6 @@ public override ValueTask ApplyChangesAsync(DocumentSessionBase session, EventSl public class custom_projection_end_to_end: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public custom_projection_end_to_end(ITestOutputHelper output) - { - _output = output; - } - private void appendCustomEvent(int number, char letter) { theSession.Events.Append(Guid.NewGuid(), new CustomEvent(number, letter)); @@ -217,8 +202,6 @@ public async Task use_strong_typed_guid_based_identifier() opts.Projections.Add(new MyCustomGuidProjection(), ProjectionLifecycle.Inline); }); - theSession.Logger = new TestOutputMartenLogger(_output); - var streamId = Guid.NewGuid(); theSession.Events.StartStream(streamId, new AEvent(), new BEvent(), new BEvent()); await theSession.SaveChangesAsync(); @@ -446,11 +429,8 @@ public override string ToString() public class using_custom_aggregate_with_soft_deletes_and_update_only_events: OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; - - public using_custom_aggregate_with_soft_deletes_and_update_only_events(ITestOutputHelper output) + public using_custom_aggregate_with_soft_deletes_and_update_only_events() { - _output = output; StoreOptions(opts => opts.Projections.Add(new StartAndStopProjection(), ProjectionLifecycle.Inline)); } @@ -583,7 +563,6 @@ public async Task return_correct_data_after_restarts() var streamForRestart = await theSession.Events.FetchForWriting(streamId, CancellationToken.None); streamForRestart.AppendOne(new Restart()); - theSession.Logger = new TestOutputMartenLogger(_output); await theSession.SaveChangesAsync(); // soft end state diff --git a/src/EventSourcingTests/Aggregation/using_guid_based_strong_typed_id_for_aggregate_identity.cs b/src/EventSourcingTests/Aggregation/using_guid_based_strong_typed_id_for_aggregate_identity.cs index 24c5659bdf..b10dc28922 100644 --- a/src/EventSourcingTests/Aggregation/using_guid_based_strong_typed_id_for_aggregate_identity.cs +++ b/src/EventSourcingTests/Aggregation/using_guid_based_strong_typed_id_for_aggregate_identity.cs @@ -119,7 +119,7 @@ public async Task can_utilize_strong_typed_id_with_async_aggregation() using var daemon = await theStore.BuildProjectionDaemonAsync(logger: testLogger); await daemon.StartAllAsync(); - await daemon.WaitForNonStaleData(1.Minutes()); + await daemon.WaitForNonStaleData(15.Seconds()); var payment = await theSession.LoadAsync(new PaymentId(id)); @@ -130,7 +130,7 @@ public async Task can_utilize_strong_typed_id_with_async_aggregation() theSession.Events.Append(id, new PaymentCanceled(DateTimeOffset.UtcNow)); await theSession.SaveChangesAsync(); - await daemon.WaitForNonStaleData(1.Minutes()); + await daemon.WaitForNonStaleData(15.Seconds()); payment = await theSession.LoadAsync(new PaymentId(id)); diff --git a/src/EventSourcingTests/Aggregation/using_string_based_strong_typed_id_for_aggregate_identity.cs b/src/EventSourcingTests/Aggregation/using_string_based_strong_typed_id_for_aggregate_identity.cs index c2c292280b..0585b0b079 100644 --- a/src/EventSourcingTests/Aggregation/using_string_based_strong_typed_id_for_aggregate_identity.cs +++ b/src/EventSourcingTests/Aggregation/using_string_based_strong_typed_id_for_aggregate_identity.cs @@ -119,7 +119,7 @@ public async Task can_utilize_strong_typed_id_with_async_aggregation() using var daemon = await theStore.BuildProjectionDaemonAsync(logger: testLogger); await daemon.StartAllAsync(); - await daemon.WaitForNonStaleData(1.Minutes()); + await daemon.WaitForNonStaleData(15.Seconds()); var payment = await theSession.LoadAsync(new Payment2Id(id)); @@ -130,7 +130,7 @@ public async Task can_utilize_strong_typed_id_with_async_aggregation() theSession.Events.Append(id, new PaymentCanceled(DateTimeOffset.UtcNow)); await theSession.SaveChangesAsync(); - await daemon.WaitForNonStaleData(1.Minutes()); + await daemon.WaitForNonStaleData(15.Seconds()); payment = await theSession.LoadAsync(new Payment2Id(id)); diff --git a/src/EventSourcingTests/Aggregation/when_doing_inline_per_stream_aggregations_with_Guid_stream_identity.cs b/src/EventSourcingTests/Aggregation/when_doing_inline_per_stream_aggregations_with_Guid_stream_identity.cs index 5bfaff26eb..20fcb9ae27 100644 --- a/src/EventSourcingTests/Aggregation/when_doing_inline_per_stream_aggregations_with_Guid_stream_identity.cs +++ b/src/EventSourcingTests/Aggregation/when_doing_inline_per_stream_aggregations_with_Guid_stream_identity.cs @@ -4,17 +4,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Aggregation; public class when_doing_inline_per_stream_aggregations_with_Guid_stream_identity : AggregationContext { - private readonly ITestOutputHelper _output; - - public when_doing_inline_per_stream_aggregations_with_Guid_stream_identity(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public when_doing_inline_per_stream_aggregations_with_Guid_stream_identity(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] diff --git a/src/EventSourcingTests/Aggregation/when_doing_live_aggregations.cs b/src/EventSourcingTests/Aggregation/when_doing_live_aggregations.cs index c361cbe5bd..fda279af37 100644 --- a/src/EventSourcingTests/Aggregation/when_doing_live_aggregations.cs +++ b/src/EventSourcingTests/Aggregation/when_doing_live_aggregations.cs @@ -10,17 +10,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Aggregation; public class when_doing_live_aggregations : AggregationContext { - private readonly ITestOutputHelper _output; - - public when_doing_live_aggregations(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public when_doing_live_aggregations(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] diff --git a/src/EventSourcingTests/Aggregation/when_using_inline_lambdas_to_define_the_projection.cs b/src/EventSourcingTests/Aggregation/when_using_inline_lambdas_to_define_the_projection.cs index 52c90148c5..65b2a62983 100644 --- a/src/EventSourcingTests/Aggregation/when_using_inline_lambdas_to_define_the_projection.cs +++ b/src/EventSourcingTests/Aggregation/when_using_inline_lambdas_to_define_the_projection.cs @@ -5,17 +5,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Aggregation; public class when_using_inline_lambdas_to_define_the_projection : AggregationContext { - private readonly ITestOutputHelper _output; - - public when_using_inline_lambdas_to_define_the_projection(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public when_using_inline_lambdas_to_define_the_projection(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] @@ -229,9 +225,6 @@ public async Task delete_based_on_system_state() theSession.Store(state1, state2); await theSession.SaveChangesAsync(); - _output.WriteLine("state1.Id is " + state1.Id); - _output.WriteLine("state2.Id is " + state2.Id); - UsingDefinition(p => { p.ProjectEvent(doc => doc.ACount++); diff --git a/src/EventSourcingTests/Bugs/Bug_1723_inline_projections_get_cut_off.cs b/src/EventSourcingTests/Bugs/Bug_1723_inline_projections_get_cut_off.cs index 99ddb62ad6..01a982b0dd 100644 --- a/src/EventSourcingTests/Bugs/Bug_1723_inline_projections_get_cut_off.cs +++ b/src/EventSourcingTests/Bugs/Bug_1723_inline_projections_get_cut_off.cs @@ -4,17 +4,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_1723_inline_projections_get_cut_off : AggregationContext { - private readonly ITestOutputHelper _output; - - public Bug_1723_inline_projections_get_cut_off(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_1723_inline_projections_get_cut_off(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] diff --git a/src/EventSourcingTests/Bugs/Bug_2025_event_inheritance_in_projection.cs b/src/EventSourcingTests/Bugs/Bug_2025_event_inheritance_in_projection.cs index 64db2efe91..c5f0451ebf 100644 --- a/src/EventSourcingTests/Bugs/Bug_2025_event_inheritance_in_projection.cs +++ b/src/EventSourcingTests/Bugs/Bug_2025_event_inheritance_in_projection.cs @@ -7,17 +7,13 @@ using Marten.Testing.Harness; using Xunit; using Shouldly; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_2025_event_inheritance_in_projection : IntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2025_event_inheritance_in_projection(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_2025_event_inheritance_in_projection(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] @@ -26,8 +22,6 @@ public async Task Create_And_Read_User_FromEventStream() await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Identity)); await theStore.Advanced.Clean.DeleteAllEventDataAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var @created = new UserCreated(Guid.NewGuid(), "google-some-name-identifier", "Nancy", "Drew"); theSession.Events.StartStream(@created.Id, created); await theSession.SaveChangesAsync(); diff --git a/src/EventSourcingTests/Bugs/Bug_2143_append_exclusive_then_append_throws_when_saving_changes.cs b/src/EventSourcingTests/Bugs/Bug_2143_append_exclusive_then_append_throws_when_saving_changes.cs index 368986fec0..18489b4978 100644 --- a/src/EventSourcingTests/Bugs/Bug_2143_append_exclusive_then_append_throws_when_saving_changes.cs +++ b/src/EventSourcingTests/Bugs/Bug_2143_append_exclusive_then_append_throws_when_saving_changes.cs @@ -3,20 +3,11 @@ using System; using System.Threading.Tasks; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_2143_append_exclusive_then_append_throws_when_saving_changes : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2143_append_exclusive_then_append_throws_when_saving_changes(ITestOutputHelper output) - { - _output = output; - - theSession.Logger = new TestOutputMartenLogger(output); - } [Fact] public async Task stream_can_be_saved_when_combining_append_exclusive_and_append() diff --git a/src/EventSourcingTests/Bugs/Bug_2260_tombstone_events_violate_streamid_version_uniqueness.cs b/src/EventSourcingTests/Bugs/Bug_2260_tombstone_events_violate_streamid_version_uniqueness.cs index 55b8382e50..9e2d7de5e2 100644 --- a/src/EventSourcingTests/Bugs/Bug_2260_tombstone_events_violate_streamid_version_uniqueness.cs +++ b/src/EventSourcingTests/Bugs/Bug_2260_tombstone_events_violate_streamid_version_uniqueness.cs @@ -8,18 +8,14 @@ using System.Threading.Tasks; using JasperFx.Events; using Xunit; -using Xunit.Abstractions; using static EventSourcingTests.appending_events_workflow_specs; namespace EventSourcingTests.Bugs; public class Bug_2260_tombstone_events_violate_streamid_version_uniqueness : IntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2260_tombstone_events_violate_streamid_version_uniqueness(ITestOutputHelper output, DefaultStoreFixture fixture) : base(fixture) + public Bug_2260_tombstone_events_violate_streamid_version_uniqueness(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Theory] @@ -41,8 +37,6 @@ public async Task subsequent_tombstone_events_increment_tombstone_stream_version theSession.QueueOperation(new FailingOperation()); - theSession.Logger = new TestOutputMartenLogger(_output); - await Should.ThrowAsync(async () => { await theSession.SaveChangesAsync(); diff --git a/src/EventSourcingTests/Bugs/Bug_2289_tombstone_events_violate_seq_id_uniqueness.cs b/src/EventSourcingTests/Bugs/Bug_2289_tombstone_events_violate_seq_id_uniqueness.cs index 53a0d3b291..2112374c3b 100644 --- a/src/EventSourcingTests/Bugs/Bug_2289_tombstone_events_violate_seq_id_uniqueness.cs +++ b/src/EventSourcingTests/Bugs/Bug_2289_tombstone_events_violate_seq_id_uniqueness.cs @@ -5,17 +5,13 @@ using System.Threading.Tasks; using JasperFx.Events; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_2289_tombstone_events_violate_seq_id_uniqueness : IntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2289_tombstone_events_violate_seq_id_uniqueness(ITestOutputHelper output, DefaultStoreFixture fixture) : base(fixture) + public Bug_2289_tombstone_events_violate_seq_id_uniqueness(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] diff --git a/src/EventSourcingTests/Bugs/Bug_2883_ievent_not_working_as_identity_source_in_multistream_projections.cs b/src/EventSourcingTests/Bugs/Bug_2883_ievent_not_working_as_identity_source_in_multistream_projections.cs index 86f26e7c32..7bdb9b8bc7 100644 --- a/src/EventSourcingTests/Bugs/Bug_2883_ievent_not_working_as_identity_source_in_multistream_projections.cs +++ b/src/EventSourcingTests/Bugs/Bug_2883_ievent_not_working_as_identity_source_in_multistream_projections.cs @@ -15,19 +15,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_2883_ievent_not_working_as_identity_source : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2883_ievent_not_working_as_identity_source(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task CanUseIEventAsSourceForIdentity() { @@ -40,7 +32,6 @@ public async Task CanUseIEventAsSourceForIdentity() { await using var session = theStore.LightweightSession(); - session.Logger = new TestOutputMartenLogger(_output); for (var i = 0; i < customersToCreate; i++) { @@ -59,7 +50,6 @@ public async Task CanUseIEventAsSourceForIdentity() var customersToDelete = 5; { await using var session = theStore.LightweightSession(); - session.Logger = new TestOutputMartenLogger(_output); for (var i = 0; i < customersToDelete; i++) { diff --git a/src/EventSourcingTests/Bugs/Bug_3310_inline_projections_with_quick_append.cs b/src/EventSourcingTests/Bugs/Bug_3310_inline_projections_with_quick_append.cs index c7a03ea8eb..dadfad4ff8 100644 --- a/src/EventSourcingTests/Bugs/Bug_3310_inline_projections_with_quick_append.cs +++ b/src/EventSourcingTests/Bugs/Bug_3310_inline_projections_with_quick_append.cs @@ -12,14 +12,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_3310_inline_projections_with_quick_append : BugIntegrationContext { - private readonly ITestOutputHelper _testOutputHelper; - // For load testing, I was using 20 iterations private const int Iterations = 3; // For load testing, I was using 1000 for NSize @@ -27,9 +24,8 @@ public class Bug_3310_inline_projections_with_quick_append : BugIntegrationConte private const string tenant = "tenant-1"; - public Bug_3310_inline_projections_with_quick_append(ITestOutputHelper testOutputHelper) + public Bug_3310_inline_projections_with_quick_append() { - _testOutputHelper = testOutputHelper; StoreOptions(opts => { opts.Events.AppendMode = EventAppendMode.Quick; @@ -49,16 +45,12 @@ public async Task start_and_append_events_to_same_stream() { await using var session = theStore.LightweightSession(tenant); - session.Logger = new TestOutputMartenLogger(_testOutputHelper); - var streamId = Guid.NewGuid().ToString(); session.Events.StartStream(streamId,new LoadTestEvent(Guid.NewGuid(), 1), new LoadTestEvent(Guid.NewGuid(), 2), new LoadTestEvent(Guid.NewGuid(), 3)); await session.SaveChangesAsync(); - _testOutputHelper.WriteLine("APPEND STARTS HERE"); - session.Events.Append(streamId, new LoadTestEvent(Guid.NewGuid(), 4), new LoadTestEvent(Guid.NewGuid(), 5)); await session.SaveChangesAsync(); @@ -83,7 +75,8 @@ public async Task create_1_stream_with_many_events() sw.Restart(); await session.SaveChangesAsync(); - _testOutputHelper.WriteLine($"{iteration:D3}: {sw.Elapsed:g}"); + + } } @@ -117,7 +110,8 @@ public async Task update_1_stream_with_many_events(bool appendWithExpectedVersio sw.Restart(); await session.SaveChangesAsync(); - _testOutputHelper.WriteLine($"{iteration:D3}: {sw.Elapsed:g}"); + + } @@ -147,7 +141,8 @@ public async Task create_many_streams_with_1_event() sw.Restart(); await session.SaveChangesAsync(); - _testOutputHelper.WriteLine($"{iteration:D3}: {sw.Elapsed:g}"); + + } } @@ -185,7 +180,8 @@ public async Task update_many_streams_with_1_event(bool appendWithExpectedVersio sw.Restart(); await session.SaveChangesAsync(); - _testOutputHelper.WriteLine($"{iteration:D3}: {sw.Elapsed:g}"); + + } // verify diff --git a/src/EventSourcingTests/Bugs/Bug_3643_using_struct_in_map_flattableprojection.cs b/src/EventSourcingTests/Bugs/Bug_3643_using_struct_in_map_flattableprojection.cs index 0f6986e2a4..e8426d0576 100644 --- a/src/EventSourcingTests/Bugs/Bug_3643_using_struct_in_map_flattableprojection.cs +++ b/src/EventSourcingTests/Bugs/Bug_3643_using_struct_in_map_flattableprojection.cs @@ -8,27 +8,17 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_3643_using_struct_in_map_flattableprojection: BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3643_using_struct_in_map_flattableprojection(ITestOutputHelper output) - { - _output = output; - } - - [Fact] public async Task add_event_that_requires_mapping_a_struct_and_a_class() { StoreOptions(x => { x.Projections.Add(ProjectionLifecycle.Inline); - x.Logger(new TestOutputMartenLogger(_output)); }); await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); diff --git a/src/EventSourcingTests/Bugs/Bug_3661_await_custom_projection_slicing.cs b/src/EventSourcingTests/Bugs/Bug_3661_await_custom_projection_slicing.cs index ddfc9aa14d..7dc5eb9d19 100644 --- a/src/EventSourcingTests/Bugs/Bug_3661_await_custom_projection_slicing.cs +++ b/src/EventSourcingTests/Bugs/Bug_3661_await_custom_projection_slicing.cs @@ -42,7 +42,7 @@ public async Task fetching_multiple_items_from_slicers_in_async_custom_projectio using var daemon = await theStore.BuildProjectionDaemonAsync(); await daemon.StartAllAsync(); - await daemon.WaitForNonStaleData(20.Seconds()); + await daemon.WaitForNonStaleData(15.Seconds()); var aggregate = await theSession.LoadAsync(stream); aggregate.Count.ShouldBe(2); diff --git a/src/EventSourcingTests/Bugs/Bug_3942_string_only_record.cs b/src/EventSourcingTests/Bugs/Bug_3942_string_only_record.cs index 97d93869f7..86025e50e4 100644 --- a/src/EventSourcingTests/Bugs/Bug_3942_string_only_record.cs +++ b/src/EventSourcingTests/Bugs/Bug_3942_string_only_record.cs @@ -30,7 +30,7 @@ public async Task start_and_append_events() var daemon = await theStore.BuildProjectionDaemonAsync(); await daemon.StartAllAsync(); - await daemon.WaitForNonStaleData(20.Seconds()); + await daemon.WaitForNonStaleData(15.Seconds()); var aggregate = await theSession.LoadAsync(stream.Key!); diff --git a/src/EventSourcingTests/Bugs/Bug_3995_start_stream_with_for_tenant_and_aggregate_type_mapper.cs b/src/EventSourcingTests/Bugs/Bug_3995_start_stream_with_for_tenant_and_aggregate_type_mapper.cs index e0afe1e804..1e5911be3f 100644 --- a/src/EventSourcingTests/Bugs/Bug_3995_start_stream_with_for_tenant_and_aggregate_type_mapper.cs +++ b/src/EventSourcingTests/Bugs/Bug_3995_start_stream_with_for_tenant_and_aggregate_type_mapper.cs @@ -10,18 +10,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Bugs; public class Bug_3995_start_stream_with_for_tenant_and_aggregate_type_mapper : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public Bug_3995_start_stream_with_for_tenant_and_aggregate_type_mapper(ITestOutputHelper output) - { - _output = output; - } + [Fact] public async Task should_have_the_aggregate_type() @@ -45,7 +40,6 @@ public async Task do_it_with_projection_document_session() StoreOptions(opts => { opts.Events.TenancyStyle = TenancyStyle.Conjoined; - opts.Logger(new TestOutputMartenLogger(_output)); }); var batch = new ProjectionUpdateBatch(theStore.Options.Projections, (DocumentSessionBase)theSession, ShardExecutionMode.Continuous, diff --git a/src/EventSourcingTests/FetchForWriting/fetching_async_aggregates_for_writing.cs b/src/EventSourcingTests/FetchForWriting/fetching_async_aggregates_for_writing.cs index 4576bb1aaa..a3899f127d 100644 --- a/src/EventSourcingTests/FetchForWriting/fetching_async_aggregates_for_writing.cs +++ b/src/EventSourcingTests/FetchForWriting/fetching_async_aggregates_for_writing.cs @@ -14,18 +14,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.FetchForWriting; public class fetching_async_aggregates_for_writing : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - public fetching_async_aggregates_for_writing(ITestOutputHelper output) - { - _output = output; - } + [Fact] public async Task fetch_new_stream_for_writing_Guid_identifier() @@ -356,7 +351,6 @@ public async Task fetch_existing_stream_exclusively_happy_path_for_writing_Guid_ new CEvent(), new CEvent()); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); var stream = await theSession.Events.FetchForExclusiveWriting(streamId); stream.Aggregate.ShouldNotBeNull(); @@ -382,7 +376,6 @@ public async Task fetch_existing_stream_exclusively_happy_path_for_writing_Guid_ new CEvent(), new CEvent()); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); var batch = theSession.CreateBatchQuery(); diff --git a/src/EventSourcingTests/FetchForWriting/fetching_inline_aggregates_for_writing.cs b/src/EventSourcingTests/FetchForWriting/fetching_inline_aggregates_for_writing.cs index af96268e1d..ea1925e4fd 100644 --- a/src/EventSourcingTests/FetchForWriting/fetching_inline_aggregates_for_writing.cs +++ b/src/EventSourcingTests/FetchForWriting/fetching_inline_aggregates_for_writing.cs @@ -16,18 +16,13 @@ using Microsoft.Extensions.Hosting; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.FetchForWriting; public class fetching_inline_aggregates_for_writing : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - public fetching_inline_aggregates_for_writing(ITestOutputHelper output) - { - _output = output; - } + [Fact] public async Task fetch_new_stream_for_writing_Guid_identifier() @@ -133,7 +128,6 @@ public async Task revision_is_updated_after_quick_appending_with_custom_mapped_v stream.AppendMany(new BEvent(), new BEvent(), new BEvent()); stream.AppendMany(new CEvent(), new CEvent()); - theSession.Logger = new TestOutputMartenLogger(_output); await theSession.SaveChangesAsync(); var document = await theSession.LoadAsync(streamId); @@ -168,7 +162,6 @@ public async Task revision_is_updated_after_quick_appending_with_custom_mapped_v stream.AppendMany(new BEvent(), new BEvent(), new BEvent()); stream.AppendMany(new CEvent(), new CEvent()); - theSession.Logger = new TestOutputMartenLogger(_output); await theSession.SaveChangesAsync(); var document = await theSession.LoadAsync(streamId); diff --git a/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_event_member_identifier_end_to_end.cs b/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_event_member_identifier_end_to_end.cs index e7bcf817af..02d6a184cf 100644 --- a/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_event_member_identifier_end_to_end.cs +++ b/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_event_member_identifier_end_to_end.cs @@ -15,18 +15,14 @@ using Weasel.Postgresql; using Weasel.Postgresql.Tables; using Xunit; -using Xunit.Abstractions; using CommandExtensions = Weasel.Core.CommandExtensions; namespace EventSourcingTests.Projections.Flattened; public class flat_table_projection_with_event_member_identifier_end_to_end: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public flat_table_projection_with_event_member_identifier_end_to_end(ITestOutputHelper output) + public flat_table_projection_with_event_member_identifier_end_to_end() { - _output = output; StoreOptions(opts => { opts.Projections.Add(ProjectionLifecycle.Inline); @@ -104,7 +100,6 @@ public async Task set_values_on_new_row() }; theSession.Events.Append(streamId, valuesSet); - theSession.Logger = new TestOutputMartenLogger(_output); await theSession.SaveChangesAsync(); var data = await findData("red"); diff --git a/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_id_identifier_end_to_end.cs b/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_id_identifier_end_to_end.cs index ec21d22092..f801d7fd08 100644 --- a/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_id_identifier_end_to_end.cs +++ b/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_id_identifier_end_to_end.cs @@ -15,18 +15,14 @@ using Weasel.Postgresql; using Weasel.Postgresql.Tables; using Xunit; -using Xunit.Abstractions; using CommandExtensions = Weasel.Postgresql.CommandExtensions; namespace EventSourcingTests.Projections.Flattened; public class flat_table_projection_with_stream_id_identifier_end_to_end: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public flat_table_projection_with_stream_id_identifier_end_to_end(ITestOutputHelper output) + public flat_table_projection_with_stream_id_identifier_end_to_end() { - _output = output; StoreOptions(opts => { opts.Projections.Add(ProjectionLifecycle.Inline); diff --git a/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_key_identifier_end_to_end.cs b/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_key_identifier_end_to_end.cs index 1d8c0712ba..13a1b3b9ea 100644 --- a/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_key_identifier_end_to_end.cs +++ b/src/EventSourcingTests/Projections/Flattened/flat_table_projection_with_stream_key_identifier_end_to_end.cs @@ -15,18 +15,14 @@ using Weasel.Postgresql; using Weasel.Postgresql.Tables; using Xunit; -using Xunit.Abstractions; using CommandExtensions = Weasel.Core.CommandExtensions; namespace EventSourcingTests.Projections.Flattened; public class flat_table_projection_with_stream_key_identifier_end_to_end: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public flat_table_projection_with_stream_key_identifier_end_to_end(ITestOutputHelper output) + public flat_table_projection_with_stream_key_identifier_end_to_end() { - _output = output; StoreOptions(opts => { opts.Projections.Add(ProjectionLifecycle.Inline); diff --git a/src/EventSourcingTests/Projections/MultiStreamProjections/rolling_up_by_tenant.cs b/src/EventSourcingTests/Projections/MultiStreamProjections/rolling_up_by_tenant.cs index 199bd81027..0f4d2dd597 100644 --- a/src/EventSourcingTests/Projections/MultiStreamProjections/rolling_up_by_tenant.cs +++ b/src/EventSourcingTests/Projections/MultiStreamProjections/rolling_up_by_tenant.cs @@ -44,7 +44,7 @@ public async Task track_totals_by_tenant_id() using var daemon = await theStore.BuildProjectionDaemonAsync(); await daemon.StartAllAsync(); - await daemon.WaitForNonStaleData(30.Seconds()); + await daemon.WaitForNonStaleData(15.Seconds()); (await theSession.LoadAsync("one")).ACount.ShouldBe(1); (await theSession.LoadAsync("two")).ACount.ShouldBe(3); @@ -81,7 +81,7 @@ public async Task track_totals_by_tenant_id_using_strong_typed_id() using var daemon = await theStore.BuildProjectionDaemonAsync(); await daemon.StartAllAsync(); - await daemon.WaitForNonStaleData(30.Seconds()); + await daemon.WaitForNonStaleData(15.Seconds()); (await theSession.LoadAsync( new TenantId("one"))).ACount.ShouldBe(1); (await theSession.LoadAsync(new TenantId("two"))).ACount.ShouldBe(3); diff --git a/src/EventSourcingTests/Projections/hiearchy_projection.cs b/src/EventSourcingTests/Projections/hiearchy_projection.cs index 66f2b1f9e9..42cd858f8e 100644 --- a/src/EventSourcingTests/Projections/hiearchy_projection.cs +++ b/src/EventSourcingTests/Projections/hiearchy_projection.cs @@ -13,18 +13,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Projections; public class hierarchy_projection : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - public hierarchy_projection(ITestOutputHelper output) - { - _output = output; - } + [Fact] public async Task try_to_use_hierarchical_with_live() diff --git a/src/EventSourcingTests/Projections/using_non_concrete_types_in_projections.cs b/src/EventSourcingTests/Projections/using_non_concrete_types_in_projections.cs index c2ec768375..577d3f3646 100644 --- a/src/EventSourcingTests/Projections/using_non_concrete_types_in_projections.cs +++ b/src/EventSourcingTests/Projections/using_non_concrete_types_in_projections.cs @@ -4,17 +4,13 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.Projections; public class using_non_concrete_types_in_projections : AggregationContext { - private readonly ITestOutputHelper _output; - - public using_non_concrete_types_in_projections(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public using_non_concrete_types_in_projections(DefaultStoreFixture fixture) : base(fixture) { - _output = output; UsingDefinition(p => { p.ProjectEvent((a, e) => 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 908add182f..0eeb04f9f6 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 @@ -14,22 +14,15 @@ using Shouldly; using Weasel.Core; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.QuickAppend; public class quick_append_event_capture_and_fetching_the_stream: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; private static readonly string[] SameTenants = { "tenant", "tenant" }; private static readonly string[] DifferentTenants = { "tenant", "differentTenant" }; private static readonly string[] DefaultTenant = { StorageConstants.DefaultTenantId }; - public quick_append_event_capture_and_fetching_the_stream(ITestOutputHelper output) - { - _output = output; - } - public static TheoryData SessionParams = new TheoryData { { TenancyStyle.Conjoined, SameTenants }, @@ -48,7 +41,6 @@ public async Task capture_events_to_a_new_stream_and_fetch_the_events_back(Tenan await When.CalledForEachAsync(tenants, async (tenantId, _) => { using var session = store.LightweightSession(tenantId); - session.Logger = new TestOutputMartenLogger(_output); var joined = new MembersJoined { Members = new[] { "Rand", "Matt", "Perrin", "Thom" } }; var departed = new MembersDeparted { Members = new[] { "Thom" } }; diff --git a/src/EventSourcingTests/QuickAppend/quick_append_events_with_optimistic_or_exclusive_locks.cs b/src/EventSourcingTests/QuickAppend/quick_append_events_with_optimistic_or_exclusive_locks.cs index 6e8df11c93..7068ea4559 100644 --- a/src/EventSourcingTests/QuickAppend/quick_append_events_with_optimistic_or_exclusive_locks.cs +++ b/src/EventSourcingTests/QuickAppend/quick_append_events_with_optimistic_or_exclusive_locks.cs @@ -8,7 +8,6 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.QuickAppend; @@ -16,13 +15,8 @@ public class quick_append_events_with_optimistic_or_exclusive_locks { public class quick_append_events_optimistic_or_exclusive_with_guid_identity: OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; - public quick_append_events_optimistic_or_exclusive_with_guid_identity(ITestOutputHelper output) - { - _output = output; - } public async Task InitializeAsync() { @@ -102,8 +96,6 @@ public async Task append_exclusive_sad_path_because_the_stream_does_not_already_ [Fact] public async Task append_exclusive_happy_path() { - theSession.Logger = new TestOutputMartenLogger(_output); - var streamId = Guid.NewGuid(); theSession.Events.StartStream(streamId, new AEvent(), new BEvent()); await theSession.SaveChangesAsync(); diff --git a/src/EventSourcingTests/QuickAppend/quick_append_timestamp.cs b/src/EventSourcingTests/QuickAppend/quick_append_timestamp.cs deleted file mode 100644 index 497f64cb2d..0000000000 --- a/src/EventSourcingTests/QuickAppend/quick_append_timestamp.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Threading.Tasks; -using EventSourcingTests.Aggregation; -using JasperFx.Core; -using JasperFx.Events; -using Marten; -using Marten.Events; -using Marten.Testing.Harness; -using Xunit; - -namespace EventSourcingTests.QuickAppend; - -public class quick_append_timestamp -{ - //[Fact] //-- this was only getting used for a one off test, but I didn't want to throw it away yet - public async Task see_the_timestamps() - { - using var store = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "timestamp"; - opts.Events.AppendMode = EventAppendMode.Quick; - }); - - await store.Advanced.Clean.DeleteAllEventDataAsync(); - - using var session = store.LightweightSession(); - session.Events.StartStream(Guid.NewGuid(), new AEvent()); - await session.SaveChangesAsync(); - - await Task.Delay(5.Seconds()); - session.Events.StartStream(Guid.NewGuid(), new AEvent()); - await session.SaveChangesAsync(); - - await Task.Delay(5.Seconds()); - session.Events.StartStream(Guid.NewGuid(), new AEvent()); - await session.SaveChangesAsync(); - - await Task.Delay(5.Seconds()); - session.Events.StartStream(Guid.NewGuid(), new AEvent()); - await session.SaveChangesAsync(); - - await Task.Delay(5.Seconds()); - session.Events.StartStream(Guid.NewGuid(), new AEvent()); - await session.SaveChangesAsync(); - - await Task.Delay(5.Seconds()); - session.Events.StartStream(Guid.NewGuid(), new AEvent()); - await session.SaveChangesAsync(); - - await Task.Delay(5.Seconds()); - session.Events.StartStream(Guid.NewGuid(), new AEvent()); - await session.SaveChangesAsync(); - } -} diff --git a/src/EventSourcingTests/QuickAppend/quick_appending_events_workflow_specs.cs b/src/EventSourcingTests/QuickAppend/quick_appending_events_workflow_specs.cs index 6eaa978cde..f40b3d1086 100644 --- a/src/EventSourcingTests/QuickAppend/quick_appending_events_workflow_specs.cs +++ b/src/EventSourcingTests/QuickAppend/quick_appending_events_workflow_specs.cs @@ -24,20 +24,14 @@ using Weasel.Core; using Weasel.Postgresql; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests.QuickAppend; [Collection("v4events")] public class quick_appending_events_workflow_specs { - private readonly ITestOutputHelper _output; - public quick_appending_events_workflow_specs(ITestOutputHelper output) - { - _output = output; - } public class EventMetadataChecker : DocumentSessionListenerBase { @@ -60,7 +54,7 @@ public override Task AfterCommitAsync(IDocumentSession session, IChangeSet commi public async Task can_fetch_stream_async(TestCase @case) { await @case.Store.Advanced.Clean.CompletelyRemoveAllAsync(); - await @case.StartNewStream(new TestOutputMartenLogger(_output)); + await @case.StartNewStream(); await using var query = @case.Store.QuerySession(); var builder = EventDocumentStorageGenerator.GenerateStorage(@case.Store.Options); @@ -93,7 +87,7 @@ public async Task can_insert_a_new_stream(TestCase @case) public async Task can_update_the_version_of_an_existing_stream_happy_path(TestCase @case) { await @case.Store.Advanced.Clean.CompletelyRemoveAllAsync(); - var stream = await @case.StartNewStream(new TestOutputMartenLogger(_output)); + var stream = await @case.StartNewStream(); stream.ExpectedVersionOnServer = 4; stream.Version = 10; @@ -104,7 +98,6 @@ public async Task can_update_the_version_of_an_existing_stream_happy_path(TestCa await using var session = @case.Store.LightweightSession(); session.QueueOperation(op); - session.Logger = new TestOutputMartenLogger(_output); await session.SaveChangesAsync(); var handler = builder.QueryForStream(stream); @@ -286,7 +279,7 @@ public TestCase(string description, Action config) internal DocumentStore Store => _store.Value; - public async Task StartNewStream(IMartenSessionLogger logger = null) + public async Task StartNewStream() { var events = new object[] {new AEvent(), new BEvent(), new CEvent(), new DEvent()}; using var session = Store.Events.TenancyStyle == TenancyStyle.Conjoined @@ -295,11 +288,6 @@ public async Task StartNewStream(IMartenSessionLogger logger = nul session.Listeners.Add(new EventMetadataChecker()); - if (logger != null) - { - session.Logger = logger; - } - if (Store.Events.StreamIdentity == StreamIdentity.AsGuid) { session.Events.StartStream(StreamId, events); diff --git a/src/EventSourcingTests/SchemaChange/Upcasters.cs b/src/EventSourcingTests/SchemaChange/Upcasters.cs index 1bcaa2dba3..5d509e355c 100644 --- a/src/EventSourcingTests/SchemaChange/Upcasters.cs +++ b/src/EventSourcingTests/SchemaChange/Upcasters.cs @@ -18,7 +18,6 @@ using Newtonsoft.Json.Linq; using Xunit; using Shouldly; -using Xunit.Abstractions; namespace EventSourcingTests.SchemaChange { @@ -782,7 +781,7 @@ public class ShoppingCartProjection: SingleStreamProjection { opts.Projections.Add(ProjectionLifecycle.Inline); - opts.Logger(new TestOutputMartenLogger(Output)); configureUpcasters(opts); }); { diff --git a/src/EventSourcingTests/append_events_with_optimistic_or_exclusive_locks.cs b/src/EventSourcingTests/append_events_with_optimistic_or_exclusive_locks.cs index 0d974a276a..8ac49b5396 100644 --- a/src/EventSourcingTests/append_events_with_optimistic_or_exclusive_locks.cs +++ b/src/EventSourcingTests/append_events_with_optimistic_or_exclusive_locks.cs @@ -8,7 +8,6 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; @@ -16,12 +15,8 @@ public class append_events_with_optimistic_or_exclusive_locks { public class append_events_optimistic_or_exclusive_with_guid_identity: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - public append_events_optimistic_or_exclusive_with_guid_identity(ITestOutputHelper output) - { - _output = output; - } + [Fact] public async Task append_optimistic_sad_path_because_the_stream_does_not_already_exist() @@ -89,8 +84,6 @@ public async Task append_exclusive_sad_path_because_the_stream_does_not_already_ [Fact] public async Task append_exclusive_happy_path() { - theSession.Logger = new TestOutputMartenLogger(_output); - var streamId = Guid.NewGuid(); theSession.Events.StartStream(streamId, new AEvent(), new BEvent()); await theSession.SaveChangesAsync(); diff --git a/src/EventSourcingTests/appending_events_workflow_specs.cs b/src/EventSourcingTests/appending_events_workflow_specs.cs index acbc0c91dd..f4f1d257da 100644 --- a/src/EventSourcingTests/appending_events_workflow_specs.cs +++ b/src/EventSourcingTests/appending_events_workflow_specs.cs @@ -27,19 +27,14 @@ using Weasel.Core; using Weasel.Postgresql; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; [Collection("v4events")] public class appending_events_workflow_specs { - private readonly ITestOutputHelper _output; - public appending_events_workflow_specs(ITestOutputHelper output) - { - _output = output; - } + public class EventMetadataChecker : DocumentSessionListenerBase { @@ -62,7 +57,7 @@ public override Task AfterCommitAsync(IDocumentSession session, IChangeSet commi public async Task can_fetch_stream_async(TestCase @case) { await @case.Store.Advanced.Clean.CompletelyRemoveAllAsync(); - await @case.StartNewStream(new TestOutputMartenLogger(_output)); + await @case.StartNewStream(); await using var query = @case.Store.QuerySession(); var builder = EventDocumentStorageGenerator.GenerateStorage(@case.Store.Options); @@ -110,7 +105,7 @@ public async Task can_insert_a_new_stream(TestCase @case) public async Task can_update_the_version_of_an_existing_stream_happy_path(TestCase @case) { await @case.Store.Advanced.Clean.CompletelyRemoveAllAsync(); - var stream = await @case.StartNewStream(new TestOutputMartenLogger(_output)); + var stream = await @case.StartNewStream(); stream.ExpectedVersionOnServer = 4; stream.Version = 10; @@ -121,7 +116,6 @@ public async Task can_update_the_version_of_an_existing_stream_happy_path(TestCa await using var session = @case.Store.LightweightSession(); session.QueueOperation(op); - session.Logger = new TestOutputMartenLogger(_output); await session.SaveChangesAsync(); var handler = builder.QueryForStream(stream); @@ -301,7 +295,7 @@ public TestCase(string description, Action config) internal DocumentStore Store => _store.Value; - public async Task StartNewStream(IMartenSessionLogger logger = null) + public async Task StartNewStream() { var events = new object[] {new AEvent(), new BEvent(), new CEvent(), new DEvent()}; using var session = Store.Events.TenancyStyle == TenancyStyle.Conjoined @@ -310,11 +304,6 @@ public async Task StartNewStream(IMartenSessionLogger logger = nul session.Listeners.Add(new EventMetadataChecker()); - if (logger != null) - { - session.Logger = logger; - } - if (Store.Events.StreamIdentity == StreamIdentity.AsGuid) { session.Events.StartStream(StreamId, events); diff --git a/src/EventSourcingTests/archiving_events.cs b/src/EventSourcingTests/archiving_events.cs index ef8afe0bc6..f0742eab62 100644 --- a/src/EventSourcingTests/archiving_events.cs +++ b/src/EventSourcingTests/archiving_events.cs @@ -21,19 +21,18 @@ using Weasel.Core; using Weasel.Postgresql; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; -public class archiving_events: OneOffConfigurationsContext +public class archiving_events: OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; - - public archiving_events(ITestOutputHelper output) + public async Task InitializeAsync() { - _output = output; + await theStore.Advanced.Clean.DeleteAllEventDataAsync(); } + public Task DisposeAsync() => Task.CompletedTask; + #region sample_archive_stream_usage public async Task SampleArchive(IDocumentSession session, string streamId) @@ -56,7 +55,7 @@ public async Task archive_stream_by_guid(bool usePartitioning) theSession.Events.StartStream(stream, new AEvent(), new BEvent(), new CEvent()); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var stream1 = await theSession.Events.FetchStreamStateAsync(stream); stream1.IsArchived.ShouldBeFalse(); @@ -99,7 +98,7 @@ public async Task archive_stream_by_guid_when_tenanted(bool usePartitioning) session.Events.StartStream(stream, new AEvent(), new BEvent(), new CEvent()); await session.SaveChangesAsync(); - session.Logger = new TestOutputMartenLogger(_output); + var stream1 = await session.Events.FetchStreamStateAsync(stream); stream1.IsArchived.ShouldBeFalse(); @@ -189,8 +188,6 @@ public async Task query_by_events_filters_out_archived_events_by_default(bool us { StoreOptions(opts => opts.Events.UseArchivedStreamPartitioning = usePartitioning); - await theStore.Advanced.Clean.DeleteAllEventDataAsync(); - var stream1 = Guid.NewGuid(); var stream2 = Guid.NewGuid(); var stream3 = Guid.NewGuid(); @@ -217,8 +214,6 @@ public async Task query_by_events_and_explicitly_search_for_archived_events(bool { StoreOptions(opts => opts.Events.UseArchivedStreamPartitioning = usePartitioning); - await theStore.Advanced.Clean.DeleteAllEventDataAsync(); - var stream1 = Guid.NewGuid(); var stream2 = Guid.NewGuid(); var stream3 = Guid.NewGuid(); @@ -229,7 +224,7 @@ public async Task query_by_events_and_explicitly_search_for_archived_events(bool await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Events.ArchiveStream(stream2); await theSession.SaveChangesAsync(); @@ -254,8 +249,6 @@ public async Task query_by_events_and_explicitly_search_for_maybe_archived_event { StoreOptions(opts => opts.Events.UseArchivedStreamPartitioning = usePartitioning); - await theStore.Advanced.Clean.DeleteAllEventDataAsync(); - var stream1 = Guid.NewGuid(); var stream2 = Guid.NewGuid(); var stream3 = Guid.NewGuid(); @@ -289,8 +282,6 @@ public async Task query_by_a_specific_event_filters_out_archived_events_by_defau { StoreOptions(opts => opts.Events.UseArchivedStreamPartitioning = usePartitioning); - await theStore.Advanced.Clean.DeleteAllEventDataAsync(); - var stream1 = Guid.NewGuid(); var stream2 = Guid.NewGuid(); var stream3 = Guid.NewGuid(); @@ -307,14 +298,6 @@ public async Task query_by_a_specific_event_filters_out_archived_events_by_defau theSession.Events.ArchiveStream(stream2); await theSession.SaveChangesAsync(); - #region sample_replacing_logger_per_session - - // We frequently use this special marten logger per - // session to pipe Marten logging to the xUnit.Net output - theSession.Logger = new TestOutputMartenLogger(_output); - - #endregion - var events = await theSession.Events.QueryRawEventDataOnly().ToListAsync(); events.Count.ShouldBe(2); @@ -328,8 +311,6 @@ public async Task prevent_append_operation_for_archived_stream_on_sync_commit(bo { StoreOptions(opts => opts.Events.UseArchivedStreamPartitioning = usePartitioning); - await theStore.Advanced.Clean.DeleteAllEventDataAsync(); - var streamId = Guid.NewGuid(); theSession.Events.Append(streamId, new AEvent()); await theSession.SaveChangesAsync(); @@ -353,8 +334,6 @@ public async Task prevent_append_operation_for_archived_stream_on_async_commit(b { StoreOptions(opts => opts.Events.UseArchivedStreamPartitioning = usePartitioning); - await theStore.Advanced.Clean.DeleteAllEventDataAsync(); - var streamId = Guid.NewGuid(); theSession.Events.Append(streamId, new AEvent()); await theSession.SaveChangesAsync(); @@ -430,7 +409,7 @@ public async Task capture_archived_event_with_async_projection_will_archive_the_ using var daemon = await theStore.BuildProjectionDaemonAsync(); await daemon.StartAllAsync(); - await daemon.WaitForNonStaleData(120.Seconds()); + await daemon.WaitForNonStaleData(15.Seconds()); // All the events should be archived var events = await theSession.Events.QueryAllRawEvents() diff --git a/src/EventSourcingTests/asserting_on_expected_event_version_on_append.cs b/src/EventSourcingTests/asserting_on_expected_event_version_on_append.cs index c66eb1ed9a..63bd26bfe3 100644 --- a/src/EventSourcingTests/asserting_on_expected_event_version_on_append.cs +++ b/src/EventSourcingTests/asserting_on_expected_event_version_on_append.cs @@ -7,14 +7,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; public class asserting_on_expected_event_version_on_append: IntegrationContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task should_check_max_event_id_on_append() { @@ -129,8 +126,6 @@ public async Task should_check_max_event_id_on_append_to_empty_stream() // and be at 5 at the end of this theSession.Events.Append(stream, 5, joined); - theSession.Logger = new TestOutputMartenLogger(_output); - await Assert.ThrowsAsync(async () => await theSession.SaveChangesAsync()); } @@ -160,8 +155,7 @@ public void should_assert_that_the_expected_version_would_be_impossible() } - public asserting_on_expected_event_version_on_append(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public asserting_on_expected_event_version_on_append(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs b/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs index 745d6ac72f..01d090dedc 100644 --- a/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs +++ b/src/EventSourcingTests/end_to_end_event_capture_and_fetching_the_stream.cs @@ -13,22 +13,15 @@ using Shouldly; using Weasel.Core; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; public class end_to_end_event_capture_and_fetching_the_stream: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; private static readonly string[] SameTenants = { "tenant", "tenant" }; private static readonly string[] DifferentTenants = { "tenant", "differentTenant" }; private static readonly string[] DefaultTenant = { StorageConstants.DefaultTenantId }; - public end_to_end_event_capture_and_fetching_the_stream(ITestOutputHelper output) - { - _output = output; - } - public static TheoryData SessionParams = new TheoryData { { TenancyStyle.Conjoined, SameTenants }, @@ -47,7 +40,6 @@ public async Task capture_events_to_a_new_stream_and_fetch_the_events_back(Tenan await When.CalledForEachAsync(tenants, async (tenantId, _) => { using var session = store.LightweightSession(tenantId); - session.Logger = new TestOutputMartenLogger(_output); #region sample_start-stream-with-aggregate-type diff --git a/src/EventSourcingTests/marking_events_as_skipped_as_Guid_identified.cs b/src/EventSourcingTests/marking_events_as_skipped_as_Guid_identified.cs index d12463f156..cc6131e450 100644 --- a/src/EventSourcingTests/marking_events_as_skipped_as_Guid_identified.cs +++ b/src/EventSourcingTests/marking_events_as_skipped_as_Guid_identified.cs @@ -12,18 +12,15 @@ using Npgsql; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; public class marking_events_as_skipped_as_Guid_identified : OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; private Guid theStreamId; - public marking_events_as_skipped_as_Guid_identified(ITestOutputHelper output) + public marking_events_as_skipped_as_Guid_identified() { - _output = output; StoreOptions(opts => { opts.Events.EnableEventSkippingInProjectionsOrSubscriptions = true; diff --git a/src/EventSourcingTests/marking_events_as_skipped_as_string_identified.cs b/src/EventSourcingTests/marking_events_as_skipped_as_string_identified.cs index 573e831f9d..1385d405b1 100644 --- a/src/EventSourcingTests/marking_events_as_skipped_as_string_identified.cs +++ b/src/EventSourcingTests/marking_events_as_skipped_as_string_identified.cs @@ -11,19 +11,16 @@ using Npgsql; using Shouldly; using Xunit; -using Xunit.Abstractions; using QueryableExtensions = Marten.QueryableExtensions; namespace EventSourcingTests; public class marking_events_as_skipped_as_string_identified : OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; private string theStreamId = Guid.NewGuid().ToString(); - public marking_events_as_skipped_as_string_identified(ITestOutputHelper output) + public marking_events_as_skipped_as_string_identified() { - _output = output; StoreOptions(opts => { opts.Events.EnableEventSkippingInProjectionsOrSubscriptions = true; diff --git a/src/EventSourcingTests/multi_tenancy_and_event_capture.cs b/src/EventSourcingTests/multi_tenancy_and_event_capture.cs index f57c949294..dfc9999661 100644 --- a/src/EventSourcingTests/multi_tenancy_and_event_capture.cs +++ b/src/EventSourcingTests/multi_tenancy_and_event_capture.cs @@ -10,14 +10,11 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; public class multi_tenancy_and_event_capture: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - public static TheoryData TenancyStyles = new TheoryData { { TenancyStyle.Conjoined }, @@ -34,7 +31,7 @@ public async Task capture_events_for_multiple_tenants_in_one_session_as_string_i }, true); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.ForTenant("one").Events.StartStream("s1", new AEvent(), new BEvent()); theSession.ForTenant("two").Events.StartStream("s1", new CEvent(), new DEvent(), new QuestStarted()); @@ -62,7 +59,7 @@ public async Task delete_all_tenant_data_catches_event_data() }, true); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.ForTenant("one").Events.StartStream("s1", new AEvent(), new BEvent()); theSession.ForTenant("two").Events.StartStream("s1", new CEvent(), new DEvent(), new QuestStarted()); @@ -90,7 +87,7 @@ public async Task capture_events_for_multiple_tenants_in_one_session_as_guid_ide var streamId = Guid.NewGuid(); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.ForTenant("one").Events.StartStream(streamId, new AEvent(), new BEvent()); theSession.ForTenant("two").Events.StartStream(streamId, new CEvent(), new DEvent(), new QuestStarted()); @@ -210,14 +207,14 @@ public async Task append_to_events_a_second_time_with_same_tenant_id(TenancyStyl Guid stream = Guid.NewGuid(); using (var session = theStore.LightweightSession("Green")) { - session.Logger = new TestOutputMartenLogger(_output); + session.Events.Append(stream, new MembersJoined(), new MembersJoined()); await session.SaveChangesAsync(); } using (var session = theStore.LightweightSession("Green")) { - session.Logger = new TestOutputMartenLogger(_output); + session.Events.Append(stream, new MembersJoined(), new MembersJoined()); await session.SaveChangesAsync(); } @@ -291,11 +288,6 @@ private void InitStore(TenancyStyle tenancyStyle, StreamIdentity streamIdentity }, true); } - public multi_tenancy_and_event_capture(ITestOutputHelper output) - { - _output = output; - } - public static TheoryData, Action, Action> WillParameterizeTenantId => new() { { diff --git a/src/EventSourcingTests/querying_event_data_with_linq.cs b/src/EventSourcingTests/querying_event_data_with_linq.cs index 01701463f9..6d1e441cf2 100644 --- a/src/EventSourcingTests/querying_event_data_with_linq.cs +++ b/src/EventSourcingTests/querying_event_data_with_linq.cs @@ -12,13 +12,11 @@ using Shouldly; using Weasel.Core; using Xunit; -using Xunit.Abstractions; namespace EventSourcingTests; public class querying_event_data_with_linq: OneOffConfigurationsContext, IAsyncLifetime { - private readonly ITestOutputHelper _output; private readonly MembersJoined joined1 = new MembersJoined { Members = new string[] { "Rand", "Matt", "Perrin", "Thom" } }; private readonly MembersDeparted departed1 = new MembersDeparted { Members = new[] { "Thom" } }; @@ -276,7 +274,6 @@ public async Task querying_with_linq_against_events_and_event_has_id_property() StoreOptions(opts => { opts.Events.StreamIdentity = StreamIdentity.AsString; - opts.Logger(new TestOutputMartenLogger(_output)); }, true); await using (var session = theStore.LightweightSession()) @@ -321,10 +318,8 @@ public void generate_proper_sql_with_querying_against_event_id() * MORE!!! * Async everything */ - public querying_event_data_with_linq(ITestOutputHelper output) - { - _output = output; - } + + } public record DummyEvent(string Id); diff --git a/src/LinqTests/Acceptance/Support/DefaultQueryFixture.cs b/src/LinqTests/Acceptance/Support/DefaultQueryFixture.cs index a0c8472e33..bc49c14edf 100644 --- a/src/LinqTests/Acceptance/Support/DefaultQueryFixture.cs +++ b/src/LinqTests/Acceptance/Support/DefaultQueryFixture.cs @@ -3,8 +3,6 @@ using Marten; using Marten.Services; using Marten.Testing.Documents; -using Xunit.Abstractions; - namespace LinqTests.Acceptance.Support; public class DefaultQueryFixture: TargetSchemaFixture, IAsyncLifetime diff --git a/src/LinqTests/Acceptance/Support/LinqTestContext.cs b/src/LinqTests/Acceptance/Support/LinqTestContext.cs index 7246dfeadf..5fcbf1505f 100644 --- a/src/LinqTests/Acceptance/Support/LinqTestContext.cs +++ b/src/LinqTests/Acceptance/Support/LinqTestContext.cs @@ -7,8 +7,6 @@ using Marten; using Marten.Testing.Documents; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Acceptance.Support; [CollectionDefinition("linq")] @@ -29,8 +27,6 @@ static LinqTestContext() _descriptions = readDescriptions(); } - protected ITestOutputHelper? TestOutput { get; set; } - protected LinqTestContext(DefaultQueryFixture fixture) { Fixture = fixture; @@ -110,7 +106,7 @@ protected async Task assertTestCaseWithDocuments(string description, IDocumentSt var testCase = testCases[index]; await using var session = store.QuerySession(); - var logger = new TestOutputMartenLogger(TestOutput); + var logger = new TestOutputMartenLogger(null); session.Logger = logger; diff --git a/src/LinqTests/Acceptance/against_date_time_offset.cs b/src/LinqTests/Acceptance/against_date_time_offset.cs index c27efe7991..bc15234d94 100644 --- a/src/LinqTests/Acceptance/against_date_time_offset.cs +++ b/src/LinqTests/Acceptance/against_date_time_offset.cs @@ -16,6 +16,7 @@ public against_date_time_offset(DefaultStoreFixture fixture) : base(fixture) [Fact] public async Task query_against_date_time_offset_that_is_not_universal_time() { + await theStore.Advanced.ResetAllData(); await theStore.BulkInsertDocumentsAsync(Target.GenerateRandomData(1000).ToArray()); var results = await theSession.Query().Where(x => x.DateOffset < DateTimeOffset.Now.AddDays(-1)) diff --git a/src/LinqTests/Acceptance/casing_support.cs b/src/LinqTests/Acceptance/casing_support.cs index a35784fac3..94dfd10e6a 100644 --- a/src/LinqTests/Acceptance/casing_support.cs +++ b/src/LinqTests/Acceptance/casing_support.cs @@ -7,14 +7,10 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class casing_support: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - [Theory] [InlineData(Casing.CamelCase)] [InlineData(Casing.SnakeCase)] @@ -31,7 +27,7 @@ public async Task serializer_casing_should_work_with_selects_newtonsoft( Casing enumStorage: EnumStorage.AsString ); - opts.Logger(new TestOutputMartenLogger(_output)); + }); await using var session = store.LightweightSession(); @@ -68,7 +64,7 @@ public async Task serializer_casing_should_work_with_selects_STJ( Casing casing) { opts.UseSystemTextJsonForSerialization(casing:casing, enumStorage:EnumStorage.AsString); - opts.Logger(new TestOutputMartenLogger(_output)); + }); await using var session = store.LightweightSession(); @@ -92,8 +88,7 @@ public async Task serializer_casing_should_work_with_selects_STJ( Casing casing) result[0].Color.ShouldBe(targets[0].Color); } - public casing_support(ITestOutputHelper output) + public casing_support() { - _output = output; } } diff --git a/src/LinqTests/Acceptance/child_collection_queries.cs b/src/LinqTests/Acceptance/child_collection_queries.cs index 92bfcb513a..b934c3a285 100644 --- a/src/LinqTests/Acceptance/child_collection_queries.cs +++ b/src/LinqTests/Acceptance/child_collection_queries.cs @@ -7,15 +7,12 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class child_collection_queries: LinqTestContext { - public child_collection_queries(DefaultQueryFixture fixture, ITestOutputHelper output) : base(fixture) + public child_collection_queries(DefaultQueryFixture fixture) : base(fixture) { - TestOutput = output; } static child_collection_queries() @@ -99,12 +96,6 @@ public Task with_duplicated_fields(string description) public class child_collection_is_empty_or_any: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public child_collection_is_empty_or_any(ITestOutputHelper output) - { - _output = output; - } protected async Task withData() { @@ -143,7 +134,6 @@ public async Task is_empty_with_value_collection() { await withData(); - theSession.Logger = new TestOutputMartenLogger(_output); var results = await theSession .Query() @@ -160,7 +150,6 @@ public async Task is_empty_with_object_collection() { await withData(); - theSession.Logger = new TestOutputMartenLogger(_output); var results = await theSession .Query() @@ -176,7 +165,6 @@ public async Task is_not_empty_with_value_collection() { await withData(); - theSession.Logger = new TestOutputMartenLogger(_output); var results = await theSession .Query() diff --git a/src/LinqTests/Acceptance/diagnostic_methods.cs b/src/LinqTests/Acceptance/diagnostic_methods.cs index 267b5170fd..9e5bddc7f2 100644 --- a/src/LinqTests/Acceptance/diagnostic_methods.cs +++ b/src/LinqTests/Acceptance/diagnostic_methods.cs @@ -6,14 +6,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class diagnostic_methods: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task retrieves_query_plan() { @@ -113,8 +109,6 @@ public void preview_basic_select_command() { var cmd = theSession.Query().ToCommand(FetchType.FetchMany); - _output.WriteLine(cmd.CommandText); - cmd.CommandText.ShouldBe($"select d.id, d.data from {SchemaName}.mt_doc_target as d;"); cmd.Parameters.Any().ShouldBeFalse(); } @@ -124,8 +118,6 @@ public void preview_select_many() { var cmd = theSession.Query().SelectMany(x => x.Children).Where(x => x.Flag) .ToCommand(FetchType.FetchMany); - - _output.WriteLine(cmd.CommandText); } [Fact] @@ -165,8 +157,7 @@ public void preview_select_on_query() } - public diagnostic_methods(ITestOutputHelper output) + public diagnostic_methods() { - _output = output; } } diff --git a/src/LinqTests/Acceptance/dictionary_usage.cs b/src/LinqTests/Acceptance/dictionary_usage.cs index 4d05efbaa4..df8a89130b 100644 --- a/src/LinqTests/Acceptance/dictionary_usage.cs +++ b/src/LinqTests/Acceptance/dictionary_usage.cs @@ -10,17 +10,12 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class dictionary_usage: IntegrationContext { - private readonly ITestOutputHelper _output; - - public dictionary_usage(DefaultStoreFixture fixture, ITestOutputHelper output): base(fixture) + public dictionary_usage(DefaultStoreFixture fixture): base(fixture) { - _output = output; } [Fact] @@ -28,14 +23,10 @@ public async Task playing() { await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Target)); - theSession.Logger = new TestOutputMartenLogger(_output); - var targets = Target.GenerateRandomData(10).ToArray(); - var number = targets.Select(x => x.StringDict).SelectMany(x => x.Values).Count(); - _output.WriteLine(number.ToString()); - + var targets = Target.GenerateRandomData(10).ToArray(); await theStore.BulkInsertAsync(targets); var data = await theSession.Query().Select(x => x.StringDict).ToListAsync(); @@ -54,7 +45,7 @@ public async Task dict_guid_can_query_using_containskey() theSession.Store(target); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var results = await theSession.Query().Where(x => x.GuidDict.ContainsKey(guid)).ToListAsync(); results.All(r => r.GuidDict.ContainsKey(guid)).ShouldBeTrue(); @@ -99,7 +90,7 @@ public async Task query_against_values() [Fact] public async Task select_many_against_the_Keys() { - theSession.Logger = new TestOutputMartenLogger(_output); + await theStore.BulkInsertAsync(Target.GenerateRandomData(1000).ToArray()); @@ -119,7 +110,7 @@ select data from mt_temp_id_list1CTE as d where d.data = 'value2' order by d.data; */ - theSession.Logger = new TestOutputMartenLogger(_output); + await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Target)); var targets = Target.GenerateRandomData(10).ToArray(); @@ -133,7 +124,7 @@ select data from mt_temp_id_list1CTE [Fact] public async Task select_many_with_wheres_and_order_by_on_values() { - theSession.Logger = new TestOutputMartenLogger(_output); + await theStore.BulkInsertAsync(Target.GenerateRandomData(1000).ToArray()); @@ -164,12 +155,6 @@ public async Task selecting_into_a_dictionary() public class dictionary_bugs : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public dictionary_bugs(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task query_by_contains_key_using_enum_as_key_with_enum_as_integer() @@ -178,7 +163,7 @@ public async Task query_by_contains_key_using_enum_as_key_with_enum_as_integer() await theStore.BulkInsertAsync(new[] { new EnumOrder("o1", new Dictionary() { [EnumA.Whatever] = "abc" }, EnumA.Whatever) }); - theSession.Logger = new TestOutputMartenLogger(_output); + var count = await theSession.Query() diff --git a/src/LinqTests/Acceptance/enum_usage.cs b/src/LinqTests/Acceptance/enum_usage.cs index 6480b95535..7bab8307f1 100644 --- a/src/LinqTests/Acceptance/enum_usage.cs +++ b/src/LinqTests/Acceptance/enum_usage.cs @@ -6,17 +6,12 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class enum_usage: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public enum_usage(ITestOutputHelper output) + public enum_usage() { - _output = output; } [Fact] diff --git a/src/LinqTests/Acceptance/identity_map_mechanics.cs b/src/LinqTests/Acceptance/identity_map_mechanics.cs index 7c43d9ba8f..dbaeff6f5b 100644 --- a/src/LinqTests/Acceptance/identity_map_mechanics.cs +++ b/src/LinqTests/Acceptance/identity_map_mechanics.cs @@ -18,6 +18,11 @@ public identity_map_mechanics(DefaultStoreFixture fixture): base(fixture) { } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + private async Task identitySessionWithData() { #region sample_using-store-with-multiple-docs diff --git a/src/LinqTests/Acceptance/matches_sql_queries.cs b/src/LinqTests/Acceptance/matches_sql_queries.cs index 05b18946fb..a21dffd66e 100644 --- a/src/LinqTests/Acceptance/matches_sql_queries.cs +++ b/src/LinqTests/Acceptance/matches_sql_queries.cs @@ -72,6 +72,11 @@ public void Throws_NotSupportedException_when_called_directly() () => new object().MatchesSql(new WhereFragment("d.data ->> 'UserName' != ?", "baz"))); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public matches_sql_queries(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Acceptance/nested_boolean_logic.cs b/src/LinqTests/Acceptance/nested_boolean_logic.cs index 42aa219ba0..45d0ca3a08 100644 --- a/src/LinqTests/Acceptance/nested_boolean_logic.cs +++ b/src/LinqTests/Acceptance/nested_boolean_logic.cs @@ -4,14 +4,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class nested_boolean_logic : IntegrationContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task TestModalOrQuery() { @@ -31,8 +27,7 @@ public async Task TestModalOrQuery() } - public nested_boolean_logic(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public nested_boolean_logic(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Acceptance/nullable_types.cs b/src/LinqTests/Acceptance/nullable_types.cs index dc0965697f..48bf12a839 100644 --- a/src/LinqTests/Acceptance/nullable_types.cs +++ b/src/LinqTests/Acceptance/nullable_types.cs @@ -5,14 +5,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class nullable_types : IntegrationContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task query_against_non_null() { @@ -85,7 +81,6 @@ public async Task query_against_nullable_bool_not_true() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); var list = await theSession.Query().Where(x => x.NullableBoolean != true).ToListAsync(); list.Count.ShouldBe(2); @@ -107,7 +102,6 @@ public async Task query_against_nullable_bool_not_false() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); var list = await theSession.Query().Where(x => x.NullableBoolean != false).ToListAsync(); list.Count.ShouldBe(2); @@ -157,8 +151,12 @@ public async Task query_against_not_null() .ShouldBe(2); } - public nullable_types(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + + public nullable_types(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Acceptance/number_filtering.cs b/src/LinqTests/Acceptance/number_filtering.cs index 783b3d8ecd..613a84908c 100644 --- a/src/LinqTests/Acceptance/number_filtering.cs +++ b/src/LinqTests/Acceptance/number_filtering.cs @@ -5,17 +5,12 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class number_filtering : IntegrationContext { - private readonly ITestOutputHelper _output; - - public number_filtering(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public number_filtering(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] @@ -67,7 +62,6 @@ public async Task can_query_by_BigInteger() using (var session = theStore.QuerySession()) { - session.Logger = new TestOutputMartenLogger(_output); var findSmallerThanMedium = await session.Query().SingleAsync(x => x.Value < MediumNumber); findSmallerThanMedium.Id.ShouldBe(1); diff --git a/src/LinqTests/Acceptance/order_by_clauses.cs b/src/LinqTests/Acceptance/order_by_clauses.cs index e35222495e..7d8b3444fc 100644 --- a/src/LinqTests/Acceptance/order_by_clauses.cs +++ b/src/LinqTests/Acceptance/order_by_clauses.cs @@ -1,15 +1,12 @@ using System.Linq; using System.Threading.Tasks; using LinqTests.Acceptance.Support; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class order_by_clauses: LinqTestContext { - public order_by_clauses(DefaultQueryFixture fixture, ITestOutputHelper output) : base(fixture) + public order_by_clauses(DefaultQueryFixture fixture) : base(fixture) { - TestOutput = output; } static order_by_clauses() diff --git a/src/LinqTests/Acceptance/order_by_sql.cs b/src/LinqTests/Acceptance/order_by_sql.cs index 96f17df93e..5edfbea2cf 100644 --- a/src/LinqTests/Acceptance/order_by_sql.cs +++ b/src/LinqTests/Acceptance/order_by_sql.cs @@ -3,17 +3,12 @@ using Marten; using Marten.Testing.Documents; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class order_by_sql : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public order_by_sql(ITestOutputHelper output) + public order_by_sql() { - _output = output; } [Fact] @@ -29,8 +24,6 @@ public async Task sort_by_literal_sql() var targets = Target.GenerateRandomData(100).ToArray(); await theStore.BulkInsertAsync(targets); - theSession.Logger = new TestOutputMartenLogger(_output); - var expected = await theSession .Query() .OrderBy(x => x.String) @@ -38,14 +31,6 @@ public async Task sort_by_literal_sql() .Select(x => x.Id) .ToListAsync(); - var command = theSession - .Query() - .OrderBySql("string") - .ThenBySql("another_string desc") - .Select(x => x.Id).ToCommand(); - - _output.WriteLine(command.CommandText); - var actual = await theSession .Query() .OrderBySql("string") diff --git a/src/LinqTests/Acceptance/query_with_inheritance.cs b/src/LinqTests/Acceptance/query_with_inheritance.cs index a35c12d79c..0119c19e97 100644 --- a/src/LinqTests/Acceptance/query_with_inheritance.cs +++ b/src/LinqTests/Acceptance/query_with_inheritance.cs @@ -8,8 +8,6 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; #region sample_smurfs-hierarchy @@ -91,13 +89,10 @@ public async Task get_all_subclasses_of_a_subclass() public class query_with_inheritance: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - #region sample_add-subclass-hierarchy - public query_with_inheritance(ITestOutputHelper output) + public query_with_inheritance() { - _output = output; StoreOptions(_ => { _.Schema.For() @@ -177,8 +172,6 @@ public async Task get_all_subclasses_of_a_subclass2() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - theSession.Query().Count().ShouldBe(2); } diff --git a/src/LinqTests/Acceptance/select_clause_usage.cs b/src/LinqTests/Acceptance/select_clause_usage.cs index 6a26113109..3cd8c02d92 100644 --- a/src/LinqTests/Acceptance/select_clause_usage.cs +++ b/src/LinqTests/Acceptance/select_clause_usage.cs @@ -405,6 +405,11 @@ public FlatTarget(Guid id, int number, int innerNumber) } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public select_clause_usage(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Acceptance/select_clauses.cs b/src/LinqTests/Acceptance/select_clauses.cs index 238fe34f87..a3e3eb5a8b 100644 --- a/src/LinqTests/Acceptance/select_clauses.cs +++ b/src/LinqTests/Acceptance/select_clauses.cs @@ -4,15 +4,12 @@ using System.Threading.Tasks; using LinqTests.Acceptance.Support; using Marten.Testing.Documents; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class select_clauses : LinqTestContext { - public select_clauses(DefaultQueryFixture fixture, ITestOutputHelper output) : base(fixture) + public select_clauses(DefaultQueryFixture fixture) : base(fixture) { - TestOutput = output; } private static void select(Expression> selector) diff --git a/src/LinqTests/Acceptance/select_many.cs b/src/LinqTests/Acceptance/select_many.cs index 71de277389..50ef10ee7d 100644 --- a/src/LinqTests/Acceptance/select_many.cs +++ b/src/LinqTests/Acceptance/select_many.cs @@ -9,14 +9,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class select_many : IntegrationContext { - private readonly ITestOutputHelper _output; - #region sample_can_do_simple_select_many_against_simple_array [Fact] public async Task can_do_simple_select_many_against_simple_array() @@ -59,7 +55,7 @@ public async Task distinct_and_count() using (var query = theStore.QuerySession()) { - query.Logger = new TestOutputMartenLogger(_output); + query .Query() .SelectMany(x => x.Tags) @@ -84,7 +80,7 @@ public async Task distinct_and_count_long() using (var query = theStore.QuerySession()) { - query.Logger = new TestOutputMartenLogger(_output); + query .Query() .SelectMany(x => x.Tags) @@ -110,7 +106,7 @@ public async Task can_do_simple_select_many_against_generic_list() using (var query = theStore.QuerySession()) { - query.Logger = new TestOutputMartenLogger(_output); + var distinct = query.Query().SelectMany(x => x.Tags).Distinct().ToList(); distinct.OrderBy(x => x).ShouldHaveTheSameElementsAs("a", "b", "c", "d", "e", "f"); @@ -300,7 +296,7 @@ public async Task select_many_with_any() query.Query().SelectMany(x => x.Tags) .Any().ShouldBeTrue(); - query.Logger = new TestOutputMartenLogger(_output); + query.Query().SelectMany(x => x.Children) .Any().ShouldBeFalse(); @@ -454,7 +450,7 @@ public async Task select_many_with_includes() using var query = theStore.LightweightSession(); var dict = new Dictionary(); - query.Logger = new TestOutputMartenLogger(_output); + var results = query.Query() .SelectMany(x => x.Children) @@ -552,8 +548,6 @@ public void try_n_deep_smoke_test() command.ShouldNotBeNull(); - _output.WriteLine(command.CommandText); - query.Query() .Where(x => x.Color == Colors.Blue) .SelectMany(x => x.Children) @@ -596,7 +590,7 @@ public async Task select_many_2_deep() } using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + var loaded = query.Query() @@ -657,7 +651,7 @@ public async Task select_many_on_value_collection_with_distinct_and_count() await theStore.BulkInsertAsync(targets); await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + var count = await query.Query().SelectMany(x => x.StringArray).Distinct().CountAsync(); @@ -674,7 +668,7 @@ public async Task select_many_on_value_collection_with_where_and_order_by() await theStore.BulkInsertAsync(targets); await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + var actual = await query.Query().Where(x => x.NumberArray != null) .SelectMany(x => x.NumberArray) @@ -699,7 +693,7 @@ public async Task select_many_on_value_collection_with_where_and_order_by_on_str await theStore.BulkInsertAsync(targets); await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + var actual = await query.Query().Where(x => x.StringArray != null) .SelectMany(x => x.StringArray) @@ -716,9 +710,13 @@ public async Task select_many_on_value_collection_with_where_and_order_by_on_str } - public select_many(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + + public select_many(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Acceptance/statistics_and_paged_list.cs b/src/LinqTests/Acceptance/statistics_and_paged_list.cs index 298b71def0..eab73e2d52 100644 --- a/src/LinqTests/Acceptance/statistics_and_paged_list.cs +++ b/src/LinqTests/Acceptance/statistics_and_paged_list.cs @@ -55,9 +55,10 @@ public statistics_and_paged_list(DefaultStoreFixture fixture) : base(fixture) } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { - return theStore.BulkInsertAsync(Target.GenerateRandomData(100).ToArray()); + await theStore.Advanced.ResetAllData(); + await theStore.BulkInsertAsync(Target.GenerateRandomData(100).ToArray()); } #region sample_compiled-query-statistics diff --git a/src/LinqTests/Acceptance/string_filtering.cs b/src/LinqTests/Acceptance/string_filtering.cs index a0bed28101..cd80ee5839 100644 --- a/src/LinqTests/Acceptance/string_filtering.cs +++ b/src/LinqTests/Acceptance/string_filtering.cs @@ -5,22 +5,19 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class string_filtering: IntegrationContext { - private readonly ITestOutputHelper _output; - - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); var entry = new User { FirstName = "Beeblebrox", Nickname = "" }; var entry2 = new User { FirstName = "Bee", Nickname = " " }; var entry3 = new User { FirstName = "Zaphod", Nickname = "Zaph" }; var entry4 = new User { FirstName = "Zap", Nickname = null }; - return theStore.BulkInsertAsync(new[] { entry, entry2, entry3, entry4 }); + await theStore.BulkInsertAsync(new[] { entry, entry2, entry3, entry4 }); } [Theory] @@ -266,8 +263,6 @@ public async Task can_search_string_with_back_slash_case_insensitive_with_String using (var query = theStore.QuerySession()) { - query.Logger = new TestOutputMartenLogger(_output); - query.Query() .Single(x => x.UserName.Equals(@"domain\test_user", StringComparison.InvariantCultureIgnoreCase)).Id .ShouldBe(user.Id); @@ -275,8 +270,7 @@ public async Task can_search_string_with_back_slash_case_insensitive_with_String } - public string_filtering(DefaultStoreFixture fixture, ITestOutputHelper output): base(fixture) + public string_filtering(DefaultStoreFixture fixture): base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Acceptance/using_dynamic_props.cs b/src/LinqTests/Acceptance/using_dynamic_props.cs index c2c9ce9abf..b9eeae6aca 100644 --- a/src/LinqTests/Acceptance/using_dynamic_props.cs +++ b/src/LinqTests/Acceptance/using_dynamic_props.cs @@ -5,14 +5,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class using_dynamic_props: IntegrationContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task order_by() { @@ -146,8 +142,6 @@ public async Task order_by_descending_then_by() [Fact] public async Task batch_order_by_descending_then_by() { - theSession.Logger = new TestOutputMartenLogger(_output); - var batch = theSession.CreateBatchQuery(); var query = batch.Query().OrderByDescending("FirstName").ThenBy("LastName").ToList(); @@ -174,8 +168,9 @@ public void when_batch_order_by_props_not_passed_throw_exception() func.ShouldThrow(); } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); theSession.Store( new User { FirstName = "Justin", LastName = "Houston" }, new User { FirstName = "Justin", LastName = "White" }, @@ -185,11 +180,10 @@ protected override Task fixtureSetup() new User { FirstName = "Harry", LastName = "Somerset" } ); - return theSession.SaveChangesAsync(); + await theSession.SaveChangesAsync(); } - public using_dynamic_props(DefaultStoreFixture fixture, ITestOutputHelper output): base(fixture) + public using_dynamic_props(DefaultStoreFixture fixture): base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Acceptance/using_explicit_sql_in_select_clauses.cs b/src/LinqTests/Acceptance/using_explicit_sql_in_select_clauses.cs index 85daa133df..341a9b37f1 100644 --- a/src/LinqTests/Acceptance/using_explicit_sql_in_select_clauses.cs +++ b/src/LinqTests/Acceptance/using_explicit_sql_in_select_clauses.cs @@ -4,17 +4,12 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class using_explicit_sql_in_select_clauses : IntegrationContext { - private readonly ITestOutputHelper _output; - - public using_explicit_sql_in_select_clauses(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public using_explicit_sql_in_select_clauses(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] @@ -25,7 +20,6 @@ public async Task using_explicit_sql_to_scalar_value() theSession.Store(new User { FirstName = "Sam", LastName = "Mitchell" }); theSession.Store(new User { FirstName = "Tom", LastName = "Chambers" }); - theSession.Logger = new TestOutputMartenLogger(_output); var firstNames = await theSession.Query().Where(x => x.FirstName == "Hank") .Select(x => x.ExplicitSql("d.data -> 'FirstName'")) @@ -42,7 +36,6 @@ public async Task using_explicit_sql_in_transform() theSession.Store(new User { FirstName = "Sam", LastName = "Mitchell" }); theSession.Store(new User { FirstName = "Tom", LastName = "Chambers" }); - theSession.Logger = new TestOutputMartenLogger(_output); var firstNames = await theSession.Query().Where(x => x.FirstName == "Hank") .Select(x => new {Name = x.ExplicitSql("d.data -> 'FirstName'")}) diff --git a/src/LinqTests/Acceptance/where_clauses.cs b/src/LinqTests/Acceptance/where_clauses.cs index feb038c87e..ec2151bc4b 100644 --- a/src/LinqTests/Acceptance/where_clauses.cs +++ b/src/LinqTests/Acceptance/where_clauses.cs @@ -4,15 +4,12 @@ using System.Threading.Tasks; using LinqTests.Acceptance.Support; using Marten; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class where_clauses: LinqTestContext { - public where_clauses(DefaultQueryFixture fixture, ITestOutputHelper output) : base(fixture) + public where_clauses(DefaultQueryFixture fixture) : base(fixture) { - TestOutput = output; } static where_clauses() diff --git a/src/LinqTests/Acceptance/where_clauses_fsharp.cs b/src/LinqTests/Acceptance/where_clauses_fsharp.cs index 48f76a6808..8cbb539d08 100644 --- a/src/LinqTests/Acceptance/where_clauses_fsharp.cs +++ b/src/LinqTests/Acceptance/where_clauses_fsharp.cs @@ -2,15 +2,12 @@ using System.Threading.Tasks; using LinqTests.Acceptance.Support; using Microsoft.FSharp.Core; -using Xunit.Abstractions; - namespace LinqTests.Acceptance; public class where_clauses_fsharp: LinqTestContext { - public where_clauses_fsharp(DefaultQueryFixture fixture, ITestOutputHelper output) : base(fixture) + public where_clauses_fsharp(DefaultQueryFixture fixture) : base(fixture) { - TestOutput = output; } static where_clauses_fsharp() diff --git a/src/LinqTests/Bugs/Bug_1219_ordering_by_attributes.cs b/src/LinqTests/Bugs/Bug_1219_ordering_by_attributes.cs index 41a374302a..76fcd23af0 100644 --- a/src/LinqTests/Bugs/Bug_1219_ordering_by_attributes.cs +++ b/src/LinqTests/Bugs/Bug_1219_ordering_by_attributes.cs @@ -5,17 +5,12 @@ using Marten.Services.Json; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_1219_ordering_by_attributes : IntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1219_ordering_by_attributes(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_1219_ordering_by_attributes(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } public class Car @@ -55,8 +50,6 @@ public void smoke_test_can_order_by_not_string_values_in_dictionary() { using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); - query.Query().OrderBy(x => x.Numbers[2]).ToList(); } } diff --git a/src/LinqTests/Bugs/Bug_1413_not_inside_of_where_against_child_collection.cs b/src/LinqTests/Bugs/Bug_1413_not_inside_of_where_against_child_collection.cs index 824c7832c1..a40c20e301 100644 --- a/src/LinqTests/Bugs/Bug_1413_not_inside_of_where_against_child_collection.cs +++ b/src/LinqTests/Bugs/Bug_1413_not_inside_of_where_against_child_collection.cs @@ -1,23 +1,20 @@ using System.Linq; +using System.Threading.Tasks; using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_1413_not_inside_of_where_against_child_collection : IntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1413_not_inside_of_where_against_child_collection(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_1413_not_inside_of_where_against_child_collection(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] - public void can_do_so() + public async Task can_do_so() { + await theStore.Advanced.ResetAllData(); var results = theSession.Query().Where(x => x.Children.Any(c => c.String == "hello" && c.Color != Colors.Blue)) .ToList(); diff --git a/src/LinqTests/Bugs/Bug_1683_query_against_dict_string_object.cs b/src/LinqTests/Bugs/Bug_1683_query_against_dict_string_object.cs index effa022b32..e0e65012b9 100644 --- a/src/LinqTests/Bugs/Bug_1683_query_against_dict_string_object.cs +++ b/src/LinqTests/Bugs/Bug_1683_query_against_dict_string_object.cs @@ -5,18 +5,10 @@ using Marten; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_1683_query_against_dict_string_object : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1683_query_against_dict_string_object(ITestOutputHelper output) - { - _output = output; - } public class MyData { @@ -33,8 +25,6 @@ public async Task try_to_query_through_dictionary_and_do_not_blow_up() theSession.Store(data1, data2); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var q1 = await theSession.Query().Where(p => p.Data["hello"] == (object)7) .FirstOrDefaultAsync(); diff --git a/src/LinqTests/Bugs/Bug_1703_Equality_Not_Symmetric.cs b/src/LinqTests/Bugs/Bug_1703_Equality_Not_Symmetric.cs index f4124894ca..cf9074265f 100644 --- a/src/LinqTests/Bugs/Bug_1703_Equality_Not_Symmetric.cs +++ b/src/LinqTests/Bugs/Bug_1703_Equality_Not_Symmetric.cs @@ -4,17 +4,17 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public sealed class Bug_1703_Equality_Not_Symmetric: IntegrationContext { - private readonly ITestOutputHelper _output; + public Bug_1703_Equality_Not_Symmetric(DefaultStoreFixture fixture) : base(fixture) + { + } - public Bug_1703_Equality_Not_Symmetric(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + protected override async Task fixtureSetup() { - _output = output; + await theStore.Advanced.ResetAllData(); } [Fact] @@ -115,8 +115,6 @@ public async Task object_equality_equals_should_be_symmetric() await using (var session = theStore.QuerySession()) { - session.Logger = new TestOutputMartenLogger(_output); - session.Query() .Where(x => x.Number.Equals(theNumber)) .ToList() diff --git a/src/LinqTests/Bugs/Bug_1884_multi_tenancy_and_Any_query.cs b/src/LinqTests/Bugs/Bug_1884_multi_tenancy_and_Any_query.cs index 876d9474bb..21418ee729 100644 --- a/src/LinqTests/Bugs/Bug_1884_multi_tenancy_and_Any_query.cs +++ b/src/LinqTests/Bugs/Bug_1884_multi_tenancy_and_Any_query.cs @@ -2,8 +2,6 @@ using System.Threading.Tasks; using Marten; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_1884_multi_tenancy_and_Any_query: BugIntegrationContext @@ -15,12 +13,11 @@ public class User public string[] Roles { get; set; } } - public Bug_1884_multi_tenancy_and_Any_query(ITestOutputHelper output) + public Bug_1884_multi_tenancy_and_Any_query() { StoreOptions(x => { x.Policies.AllDocumentsAreMultiTenanted(); - x.Logger(new TestOutputMartenLogger(output)); }); } diff --git a/src/LinqTests/Bugs/Bug_1951_querying_against_nested_enum.cs b/src/LinqTests/Bugs/Bug_1951_querying_against_nested_enum.cs index a98212aa28..1aa1885b6e 100644 --- a/src/LinqTests/Bugs/Bug_1951_querying_against_nested_enum.cs +++ b/src/LinqTests/Bugs/Bug_1951_querying_against_nested_enum.cs @@ -5,23 +5,15 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_1951_querying_against_nested_enum : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_1951_querying_against_nested_enum(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task can_query_against_the_nested_enum() { - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Store(new TestDoc { Nested = new Nested(Guid.NewGuid(), Scope.Periscope) @@ -49,7 +41,7 @@ public async Task can_query_against_the_nested_enum_stored_as_string() opts.UseSystemTextJsonForSerialization(EnumStorage.AsString); }); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Store(new TestDoc { Nested = new Nested(Guid.NewGuid(), Scope.Periscope) diff --git a/src/LinqTests/Bugs/Bug_2224_Include_needs_to_respect_Take_and_Skip_in_main_body.cs b/src/LinqTests/Bugs/Bug_2224_Include_needs_to_respect_Take_and_Skip_in_main_body.cs index c9c403eeef..99bd72ae74 100644 --- a/src/LinqTests/Bugs/Bug_2224_Include_needs_to_respect_Take_and_Skip_in_main_body.cs +++ b/src/LinqTests/Bugs/Bug_2224_Include_needs_to_respect_Take_and_Skip_in_main_body.cs @@ -8,18 +8,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2224_Include_needs_to_respect_Take_and_Skip_in_main_body: BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2224_Include_needs_to_respect_Take_and_Skip_in_main_body(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task include_to_list_using_inner_join_and_paging() @@ -37,7 +29,7 @@ public async Task include_to_list_using_inner_join_and_paging() await theSession.SaveChangesAsync(); await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + var list = new List(); var issues = await query.Query() @@ -67,7 +59,7 @@ public async Task include_to_list_using_inner_join_and_paging_and_ordering() await theSession.SaveChangesAsync(); await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + var list = new List(); var issues = await query.Query() @@ -96,7 +88,6 @@ public async Task Bug_2258_get_all_related_documents() theSession.Store(user1); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); var tenants = new Dictionary(); var user = await theSession @@ -123,7 +114,6 @@ public async Task include_with_pagination() await theStore.BulkInsertAsync(targets); await theStore.BulkInsertAsync(users); - theSession.Logger = new TestOutputMartenLogger(_output); var dict = new Dictionary(); var records = await theSession.Query() diff --git a/src/LinqTests/Bugs/Bug_2433_include_with_take.cs b/src/LinqTests/Bugs/Bug_2433_include_with_take.cs index b533255ae8..f9f7e53547 100644 --- a/src/LinqTests/Bugs/Bug_2433_include_with_take.cs +++ b/src/LinqTests/Bugs/Bug_2433_include_with_take.cs @@ -21,6 +21,7 @@ public Bug_2433_include_with_take(DefaultStoreFixture fixture): base(fixture) [InlineData(true, 1, 2)] public async Task should_include_proper_related_documents(bool useOrderBy, int pageNumber, int pageSize) { + await theStore.Advanced.ResetAllData(); // Arrange var countries = new[] { diff --git a/src/LinqTests/Bugs/Bug_2553_Include_with_ToPagedList.cs b/src/LinqTests/Bugs/Bug_2553_Include_with_ToPagedList.cs index 176c88d900..c2ea53d43e 100644 --- a/src/LinqTests/Bugs/Bug_2553_Include_with_ToPagedList.cs +++ b/src/LinqTests/Bugs/Bug_2553_Include_with_ToPagedList.cs @@ -5,23 +5,14 @@ using Marten.Pagination; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2553_Include_with_ToPagedList: BugIntegrationContext { - private readonly ITestOutputHelper _output; - public record Foo(Guid Id); public record Bar(Guid Id, Guid FooId); - public Bug_2553_Include_with_ToPagedList(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task query_should_return_included_docs() { @@ -42,7 +33,6 @@ public async Task query_should_return_included_docs() var includedFoos = new Dictionary(); - theSession.Logger = new TestOutputMartenLogger(_output); var queriedBars = await theSession.Query() .Include(bar => bar.FooId, dictionary: includedFoos) .ToPagedListAsync(pageNumber: 1, pageSize: 4); diff --git a/src/LinqTests/Bugs/Bug_2563_sub_collection_queries_and_OR.cs b/src/LinqTests/Bugs/Bug_2563_sub_collection_queries_and_OR.cs index 94beab79f8..85a47defb5 100644 --- a/src/LinqTests/Bugs/Bug_2563_sub_collection_queries_and_OR.cs +++ b/src/LinqTests/Bugs/Bug_2563_sub_collection_queries_and_OR.cs @@ -3,18 +3,10 @@ using Marten; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2563_sub_collection_queries_and_OR : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2563_sub_collection_queries_and_OR(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task get_distinct_number() @@ -30,9 +22,6 @@ public async Task get_distinct_number() theSession.Store(new Bug2563Target {Id = 6, IsPublic = true, UserIds = [10]}); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - - var result1 = await theSession.Query() .Where(x => x.IsPublic == false || x.UserIds.Contains(10)) .ToListAsync(); diff --git a/src/LinqTests/Bugs/Bug_260_Take_Skip_with_Select_Tests.cs b/src/LinqTests/Bugs/Bug_260_Take_Skip_with_Select_Tests.cs index c0b04e1a48..505583edbc 100644 --- a/src/LinqTests/Bugs/Bug_260_Take_Skip_with_Select_Tests.cs +++ b/src/LinqTests/Bugs/Bug_260_Take_Skip_with_Select_Tests.cs @@ -13,6 +13,7 @@ public class Bug_260_Take_Skip_with_Select_Tests: IntegrationContext [Fact] public async Task return_the_correct_number_of_results() { + await theStore.Advanced.ResetAllData(); var targets = Target.GenerateRandomData(100); await theStore.BulkInsertAsync(targets.ToArray()); diff --git a/src/LinqTests/Bugs/Bug_2618_Include_with_AnyTenant.cs b/src/LinqTests/Bugs/Bug_2618_Include_with_AnyTenant.cs index da941b8c91..feb20ed11e 100644 --- a/src/LinqTests/Bugs/Bug_2618_Include_with_AnyTenant.cs +++ b/src/LinqTests/Bugs/Bug_2618_Include_with_AnyTenant.cs @@ -5,18 +5,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2618_Include_with_AnyTenant : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2618_Include_with_AnyTenant(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task tenant_filter_should_apply_to_both_parent_and_child_documents() @@ -48,8 +40,6 @@ public async Task tenant_filter_should_apply_to_both_parent_and_child_documents( await session.SaveChangesAsync(); } - theSession.Logger = new TestOutputMartenLogger(_output); - var users = new List(); var issues = await theSession diff --git a/src/LinqTests/Bugs/Bug_261_double_take_or_skip.cs b/src/LinqTests/Bugs/Bug_261_double_take_or_skip.cs index 07741fdf8a..676e5a2903 100644 --- a/src/LinqTests/Bugs/Bug_261_double_take_or_skip.cs +++ b/src/LinqTests/Bugs/Bug_261_double_take_or_skip.cs @@ -38,6 +38,11 @@ public async Task one_more_try() result.Count.ShouldBe(4); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public Bug_261_double_take_or_skip(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Bugs/Bug_2810_distinct_plus_include.cs b/src/LinqTests/Bugs/Bug_2810_distinct_plus_include.cs index 0f9eab441f..75824df876 100644 --- a/src/LinqTests/Bugs/Bug_2810_distinct_plus_include.cs +++ b/src/LinqTests/Bugs/Bug_2810_distinct_plus_include.cs @@ -4,19 +4,10 @@ using Marten; using Marten.Schema; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2810_distinct_plus_include : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2810_distinct_plus_include(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task do_not_blow_up() { @@ -25,8 +16,6 @@ public async Task do_not_blow_up() var skip = 30; var take = 10; - theSession.Logger = new TestOutputMartenLogger(_output); - var results = await theSession.Query() .Include(x => x.IncludedTableId, includedTableDocuments) .Where(i => i.ExportId == exportId) diff --git a/src/LinqTests/Bugs/Bug_2896_count_plus_HashSet.cs b/src/LinqTests/Bugs/Bug_2896_count_plus_HashSet.cs index 97b81df429..1f1caed3f1 100644 --- a/src/LinqTests/Bugs/Bug_2896_count_plus_HashSet.cs +++ b/src/LinqTests/Bugs/Bug_2896_count_plus_HashSet.cs @@ -5,24 +5,13 @@ using Marten; using Marten.Testing.Documents; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2896_count_plus_HashSet : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2896_count_plus_HashSet(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task try_to_query() { - theSession.Logger = new TestOutputMartenLogger(_output); - var guidList = new HashSet() { Guid.NewGuid() }; var count = await theSession .Query() diff --git a/src/LinqTests/Bugs/Bug_2934_multiple_nested_conditionals.cs b/src/LinqTests/Bugs/Bug_2934_multiple_nested_conditionals.cs index 7a8815efae..b791faabf9 100644 --- a/src/LinqTests/Bugs/Bug_2934_multiple_nested_conditionals.cs +++ b/src/LinqTests/Bugs/Bug_2934_multiple_nested_conditionals.cs @@ -4,31 +4,18 @@ using System.Threading.Tasks; using Marten; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2934_multiple_nested_conditionals : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public record NestedObject(Guid[] Guids, Guid[] MoreGuids, List Obj); public record ObjectWithGuids(Guid Id, NestedObject NestedObject, string SomeText); - public Bug_2934_multiple_nested_conditionals(ITestOutputHelper output) - { - _output = output; - - theSession.Logger = new TestOutputMartenLogger(_output); - } - [Fact] public async Task broken_linq_condition_1() { var array = new[] { Guid.NewGuid() }; - theSession.Logger = new TestOutputMartenLogger(_output); - await theSession.Query().Where(x => !array.Any() || x.NestedObject.Guids.Any(z => array.Contains(z)) @@ -42,8 +29,6 @@ public async Task Bug_3025_broken_linq_condition_2() var parameterIds = new[] { Guid.NewGuid() }; var guid = Guid.NewGuid(); - theSession.Logger = new TestOutputMartenLogger(_output); - await theSession.Query().Where(x => !parameterIds.Any() || x.NestedObject.Guids.Any(z => parameterIds.Contains(z)) diff --git a/src/LinqTests/Bugs/Bug_2935_any_contains_in_child_collection.cs b/src/LinqTests/Bugs/Bug_2935_any_contains_in_child_collection.cs index 114fc52d0d..d81d04ba61 100644 --- a/src/LinqTests/Bugs/Bug_2935_any_contains_in_child_collection.cs +++ b/src/LinqTests/Bugs/Bug_2935_any_contains_in_child_collection.cs @@ -4,29 +4,18 @@ using System.Threading.Tasks; using Marten; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2935_any_contains_in_child_collection : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public record NestedObject(Guid[] Guids, Guid[] MoreGuids, List Obj); public record ObjectWithGuids(Guid Id, NestedObject NestedObject, string SomeText); - public Bug_2935_any_contains_in_child_collection(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task broken_linq_condition_2() { var id = Guid.NewGuid(); - theSession.Logger = new TestOutputMartenLogger(_output); - await theSession.Query().Where(x => x.NestedObject.Obj.Any(obj => obj.Guids.Contains(id))) .ToListAsync(); diff --git a/src/LinqTests/Bugs/Bug_2936_static_list.cs b/src/LinqTests/Bugs/Bug_2936_static_list.cs index c2d844e33f..53c7404fdc 100644 --- a/src/LinqTests/Bugs/Bug_2936_static_list.cs +++ b/src/LinqTests/Bugs/Bug_2936_static_list.cs @@ -4,26 +4,16 @@ using System.Threading.Tasks; using Marten; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2936_static_list : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public record NestedObject(Guid[] Guids, Guid[] MoreGuids, List Obj); public record ObjectWithGuids(Guid Id, NestedObject NestedObject, string SomeText); - public Bug_2936_static_list(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task broken_linq_condition_3() { - theSession.Logger = new TestOutputMartenLogger(_output); await theSession.Query().Where(x => SomeData.ConstantList.Contains(x.SomeText)) .ToListAsync(); } diff --git a/src/LinqTests/Bugs/Bug_2937_string_isnullorempty_being_ignored.cs b/src/LinqTests/Bugs/Bug_2937_string_isnullorempty_being_ignored.cs index bc405b6749..e501c8fa97 100644 --- a/src/LinqTests/Bugs/Bug_2937_string_isnullorempty_being_ignored.cs +++ b/src/LinqTests/Bugs/Bug_2937_string_isnullorempty_being_ignored.cs @@ -3,22 +3,12 @@ using System.Threading.Tasks; using Marten; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_2937_string_isnullorempty_being_ignored : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public record ObjectWithString(Guid Id, string String); - public Bug_2937_string_isnullorempty_being_ignored(ITestOutputHelper output) - { - _output = output; - theSession.Logger = new TestOutputMartenLogger(_output); - } - [Fact] public async Task broken_linq_condition_4() { diff --git a/src/LinqTests/Bugs/Bug_3024_wildcards_in_string_insensitive_comparisons.cs b/src/LinqTests/Bugs/Bug_3024_wildcards_in_string_insensitive_comparisons.cs index 4b3e45afa4..b37bf84c38 100644 --- a/src/LinqTests/Bugs/Bug_3024_wildcards_in_string_insensitive_comparisons.cs +++ b/src/LinqTests/Bugs/Bug_3024_wildcards_in_string_insensitive_comparisons.cs @@ -3,18 +3,10 @@ using System.Threading.Tasks; using Marten; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3024_wildcards_in_string_insensitive_comparisons : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3024_wildcards_in_string_insensitive_comparisons(ITestOutputHelper output) - { - _output = output; - } public record ComparisionRecord(Guid Id, string Data); @@ -24,8 +16,6 @@ public async Task ignore_case_with_percentage_wildcard_should_not_impact_results theSession.Store(new ComparisionRecord(Guid.NewGuid(), "MyString")); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var results = await theSession.Query() .Where(x => x.Data.Equals("%MyString", StringComparison.OrdinalIgnoreCase)) .ToListAsync(); diff --git a/src/LinqTests/Bugs/Bug_3027_using_string_null_check.cs b/src/LinqTests/Bugs/Bug_3027_using_string_null_check.cs index cfc83da9eb..2c5e2b835b 100644 --- a/src/LinqTests/Bugs/Bug_3027_using_string_null_check.cs +++ b/src/LinqTests/Bugs/Bug_3027_using_string_null_check.cs @@ -4,18 +4,10 @@ using Marten; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3027_using_string_null_check : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3027_using_string_null_check(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task broken_linq_condition_3() @@ -26,8 +18,6 @@ public async Task broken_linq_condition_3() await theSession.SaveChangesAsync(); string? str = null; - theSession.Logger = new TestOutputMartenLogger(_output); - var query = await theSession.Query() .Where(x=> x.FilterGuid == guid && (str == null || x.SomeText == str)).ToListAsync(); diff --git a/src/LinqTests/Bugs/Bug_3030_nested_array_queries.cs b/src/LinqTests/Bugs/Bug_3030_nested_array_queries.cs index 0797b40b92..931cba56e1 100644 --- a/src/LinqTests/Bugs/Bug_3030_nested_array_queries.cs +++ b/src/LinqTests/Bugs/Bug_3030_nested_array_queries.cs @@ -5,23 +5,14 @@ using Marten; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3030_nested_array_queries : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public sealed record NestedObject2(List MyPileOfGuids); public sealed record NestedObject1(List NestedObject2s); public sealed record RootObject(Guid Id, NestedObject1 NestedObject); - public Bug_3030_nested_array_queries(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task Bug_nested_array_querying() { @@ -33,8 +24,6 @@ public async Task Bug_nested_array_querying() theSession.Store(entity); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var result = await theSession.Query() .Where(x => x.NestedObject.NestedObject2s.Any(y => y.MyPileOfGuids.Contains(searchGuid))) .SingleOrDefaultAsync(); diff --git a/src/LinqTests/Bugs/Bug_3031_querying_using_soft_deletes.cs b/src/LinqTests/Bugs/Bug_3031_querying_using_soft_deletes.cs index 512891a331..9dbb94eb15 100644 --- a/src/LinqTests/Bugs/Bug_3031_querying_using_soft_deletes.cs +++ b/src/LinqTests/Bugs/Bug_3031_querying_using_soft_deletes.cs @@ -5,18 +5,10 @@ using Marten.Metadata; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3031_querying_using_soft_deletes : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3031_querying_using_soft_deletes(ITestOutputHelper output) - { - _output = output; - } public static IQueryable AddWhere(IQueryable q) { @@ -84,8 +76,6 @@ public async Task test_any_maybe_deleted_in_generic_extension_method() using var session = theStore.QuerySession(); - session.Logger = new TestOutputMartenLogger(_output); - bool result = session .Query() .WithArchivedState(ArchivedState.IncludeArchived) diff --git a/src/LinqTests/Bugs/Bug_3032_serialization_error_combined_Select_and_Include.cs b/src/LinqTests/Bugs/Bug_3032_serialization_error_combined_Select_and_Include.cs index f749117e4c..8b6b3f1383 100644 --- a/src/LinqTests/Bugs/Bug_3032_serialization_error_combined_Select_and_Include.cs +++ b/src/LinqTests/Bugs/Bug_3032_serialization_error_combined_Select_and_Include.cs @@ -7,18 +7,10 @@ using Marten.Services; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3032_serialization_error_combined_Select_and_Include : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3032_serialization_error_combined_Select_and_Include(ITestOutputHelper output) - { - _output = output; - } // Fails with error: // Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IReadOnlyList`1 @@ -52,7 +44,7 @@ public async Task test_select_and_include() } await using var session = theStore.QuerySession(); - session.Logger = new TestOutputMartenLogger(_output); + var metadata = new List(); var result = await session @@ -142,7 +134,7 @@ public async Task test_just_select() } await using var session = theStore.QuerySession(); - session.Logger = new TestOutputMartenLogger(_output); + var result = await session .Query() .Where(x => x.Id.IsOneOf(entity.Id)) diff --git a/src/LinqTests/Bugs/Bug_3035_crazy_nested_boolean_conditions.cs b/src/LinqTests/Bugs/Bug_3035_crazy_nested_boolean_conditions.cs index 61e5ad7919..5756e1c484 100644 --- a/src/LinqTests/Bugs/Bug_3035_crazy_nested_boolean_conditions.cs +++ b/src/LinqTests/Bugs/Bug_3035_crazy_nested_boolean_conditions.cs @@ -5,18 +5,10 @@ using Marten; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3035_crazy_nested_boolean_conditions : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3035_crazy_nested_boolean_conditions(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task behave_correctly_if_comparing_to_null_string() @@ -72,8 +64,6 @@ public async Task behave_correctly_if_comparing_to_null_string() list.Any(x => x.Id == activeDetails.Id).ShouldBeTrue(); list.Any(x => x.Id == inactiveDetails.Id).ShouldBeTrue(); - theSession.Logger = new TestOutputMartenLogger(_output); - var list2 = await GetTrackWarrantsForTerritory(territoryId, null); list2.Single().Id.ShouldBe(activeDetails.Id); } diff --git a/src/LinqTests/Bugs/Bug_3065_include_query_with_conjoined_tenancy.cs b/src/LinqTests/Bugs/Bug_3065_include_query_with_conjoined_tenancy.cs index 4da0ee8364..a3f95466ce 100644 --- a/src/LinqTests/Bugs/Bug_3065_include_query_with_conjoined_tenancy.cs +++ b/src/LinqTests/Bugs/Bug_3065_include_query_with_conjoined_tenancy.cs @@ -3,19 +3,12 @@ using Marten; using Marten.Testing.Documents; using Marten.Testing.Harness; -using Xunit.Abstractions; using Shouldly; namespace LinqTests.Bugs; public class Bug_3065_include_query_with_conjoined_tenancy : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3065_include_query_with_conjoined_tenancy(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task include_with_SingleOrDefault_where_for_a_single_document() @@ -42,8 +35,6 @@ public async Task include_with_SingleOrDefault_where_for_a_single_document() await using var query = theStore.QuerySession("a"); - query.Logger = new TestOutputMartenLogger(_output); - User included = null; var issueLoaded = await query .Query() diff --git a/src/LinqTests/Bugs/Bug_3066_calling_static_methods_in_queries.cs b/src/LinqTests/Bugs/Bug_3066_calling_static_methods_in_queries.cs index 8383dd8d1a..1f1d1e30b7 100644 --- a/src/LinqTests/Bugs/Bug_3066_calling_static_methods_in_queries.cs +++ b/src/LinqTests/Bugs/Bug_3066_calling_static_methods_in_queries.cs @@ -3,18 +3,10 @@ using Marten; using Marten.Testing.Documents; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3066_calling_static_methods_in_queries : BugIntegrationContext { - private readonly ITestOutputHelper _testOutputHelper; - - public Bug_3066_calling_static_methods_in_queries(ITestOutputHelper testOutputHelper) - { - _testOutputHelper = testOutputHelper; - } [Fact] public async Task GettingPropertyFromTypedObjectCreatedFromStaticMethod() @@ -25,7 +17,6 @@ public async Task GettingPropertyFromTypedObjectCreatedFromStaticMethod() }); var queryPlan = await theSession.Query().Where(x => x.Id == AccountId.New("123").Value).ExplainAsync(); - _testOutputHelper.WriteLine(queryPlan.Command.CommandText); } public record AccountId(string Value) diff --git a/src/LinqTests/Bugs/Bug_3067_nested_array_in_dictionary.cs b/src/LinqTests/Bugs/Bug_3067_nested_array_in_dictionary.cs index de12398401..af2800e09b 100644 --- a/src/LinqTests/Bugs/Bug_3067_nested_array_in_dictionary.cs +++ b/src/LinqTests/Bugs/Bug_3067_nested_array_in_dictionary.cs @@ -6,22 +6,13 @@ using Marten.Exceptions; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3067_nested_array_in_dictionary : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public record RootRecord(Guid Id, Dictionary Dict); public record NestedRecord(List Entities); - public Bug_3067_nested_array_in_dictionary(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task filter_with_dict_list_nested() { @@ -33,8 +24,6 @@ public async Task filter_with_dict_list_nested() theSession.Store(new RootRecord(Guid.NewGuid(), new Dictionary() { {Guid.NewGuid(), new NestedRecord([Guid.NewGuid()])}, {Guid.NewGuid(), new NestedRecord([Guid.NewGuid()])}})); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var ex = await Should.ThrowAsync(async () => { var results = await theSession.Query(). diff --git a/src/LinqTests/Bugs/Bug_3087_using_JsonPath_with_MatchesSql.cs b/src/LinqTests/Bugs/Bug_3087_using_JsonPath_with_MatchesSql.cs index 4d655d9c3c..15c46fc73b 100644 --- a/src/LinqTests/Bugs/Bug_3087_using_JsonPath_with_MatchesSql.cs +++ b/src/LinqTests/Bugs/Bug_3087_using_JsonPath_with_MatchesSql.cs @@ -4,25 +4,16 @@ using Marten.Linq.MatchesSql; using Marten.Testing.Documents; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3087_using_JsonPath_with_MatchesSql : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3087_using_JsonPath_with_MatchesSql(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task can_use_json_path_operations() { await theStore.BulkInsertDocumentsAsync(Target.GenerateRandomData(100).ToArray()); - theSession.Logger = new TestOutputMartenLogger(_output); var results = await theSession.Query().Where(x => !x.Children.Any()).ToListAsync(); #region sample_using_MatchesJsonPath diff --git a/src/LinqTests/Bugs/Bug_3096_include_where_select.cs b/src/LinqTests/Bugs/Bug_3096_include_where_select.cs index 26b994db7f..696567a147 100644 --- a/src/LinqTests/Bugs/Bug_3096_include_where_select.cs +++ b/src/LinqTests/Bugs/Bug_3096_include_where_select.cs @@ -6,17 +6,12 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3096_include_where_select : IntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3096_include_where_select(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_3096_include_where_select(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] @@ -35,8 +30,6 @@ public async Task include_to_dictionary_with_where_and_projection() await session.SaveChangesAsync(); using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); - var dict = new Dictionary(); var issues = query diff --git a/src/LinqTests/Bugs/Bug_3126_dictionary_nested_queries.cs b/src/LinqTests/Bugs/Bug_3126_dictionary_nested_queries.cs index f17914b052..67c23066e4 100644 --- a/src/LinqTests/Bugs/Bug_3126_dictionary_nested_queries.cs +++ b/src/LinqTests/Bugs/Bug_3126_dictionary_nested_queries.cs @@ -6,22 +6,13 @@ using Marten.Exceptions; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3126_dictionary_nested_queries : BugIntegrationContext { - private readonly ITestOutputHelper _output; - public record DictObject(Guid Id, Dictionary> GuidDict, Dictionary NestedObject); public record NestedObjectWithinDict(Guid Id); - public Bug_3126_dictionary_nested_queries(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task broken_linq_condition_3() { @@ -42,8 +33,6 @@ public async Task broken_linq_condition_3() await theStore.BulkInsertDocumentsAsync([o, main]); - theSession.Logger = new TestOutputMartenLogger(_output); - await Should.ThrowAsync(async () => { await theSession.Query() diff --git a/src/LinqTests/Bugs/Bug_3151_using_duplicated_fields_in_linq_queries.cs b/src/LinqTests/Bugs/Bug_3151_using_duplicated_fields_in_linq_queries.cs index 8aada84c10..3ef127377d 100644 --- a/src/LinqTests/Bugs/Bug_3151_using_duplicated_fields_in_linq_queries.cs +++ b/src/LinqTests/Bugs/Bug_3151_using_duplicated_fields_in_linq_queries.cs @@ -6,18 +6,10 @@ using Marten.Schema; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3151_using_duplicated_fields_in_linq_queries : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3151_using_duplicated_fields_in_linq_queries(ITestOutputHelper output) - { - _output = output; - } [Fact] @@ -62,8 +54,6 @@ await theSession.Query() .ToListAsync(); } - theSession.Logger = new TestOutputMartenLogger(_output); - await DoQuery(); // second invocation throws MartenCommandException "42P01: relation "mt_temp_id_list1" does not exist" diff --git a/src/LinqTests/Bugs/Bug_3337_select_page.cs b/src/LinqTests/Bugs/Bug_3337_select_page.cs index cd117f8aa5..b712a26ae6 100644 --- a/src/LinqTests/Bugs/Bug_3337_select_page.cs +++ b/src/LinqTests/Bugs/Bug_3337_select_page.cs @@ -6,25 +6,15 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_3337_select_page : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3337_select_page(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task try_it_out() { await theStore.BulkInsertAsync(Target.GenerateRandomData(1000).ToArray()); - theSession.Logger = new TestOutputMartenLogger(_output); var results = await theSession.Query().Where(x => x.Inner != null) .Select(x => new SelectedGuy() { Id = x.Id, Number = x.Inner.Number, Text = x.String }) .Take(5).Stats(out var statistics).ToListAsync(); diff --git a/src/LinqTests/Bugs/Bug_432_querying_with_UTC_times_with_offset.cs b/src/LinqTests/Bugs/Bug_432_querying_with_UTC_times_with_offset.cs index 944f867135..49f0dbe625 100644 --- a/src/LinqTests/Bugs/Bug_432_querying_with_UTC_times_with_offset.cs +++ b/src/LinqTests/Bugs/Bug_432_querying_with_UTC_times_with_offset.cs @@ -5,19 +5,10 @@ using Marten; using Marten.Testing.Harness; using Shouldly; -using Weasel.Postgresql; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_432_querying_with_UTC_times_with_offset: BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_432_querying_with_UTC_times_with_offset(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task can_issue_queries_against_DateTime() @@ -25,7 +16,7 @@ public async Task can_issue_queries_against_DateTime() using (var session = theStore.LightweightSession()) { var now = GenerateTestDateTime(); - _output.WriteLine("now: " + now.ToString("o")); + var testClass = new DateClass { Id = Guid.NewGuid(), @@ -46,25 +37,6 @@ public async Task can_issue_queries_against_DateTime() await session.SaveChangesAsync(); - var cmd = session.Query().Where(x => now >= x.DateTimeField) - .ToCommand(); - - _output.WriteLine(cmd.CommandText); - - var sql = $"select {SchemaName}.mt_immutable_timestamp(d.data ->> \'DateTimeField\') as time from {SchemaName}.mt_doc_dateclass as d"; - - using (var reader = session.Connection.CreateCommand(sql).ExecuteReader()) - { - while (reader.Read()) - { - _output.WriteLine("stored: " + reader.GetDateTime(0).ToString("o")); - } - } - - session.Query().ToList().Each(x => - { - _output.WriteLine(x.DateTimeField.ToString("o")); - }); session.Query() .Count(x => now >= x.DateTimeField).ShouldBe(2); @@ -79,7 +51,7 @@ public async Task can_issue_queries_against_DateTime_with_camel_casing() using (var session = theStore.LightweightSession()) { var now = GenerateTestDateTime(); - _output.WriteLine("now: " + now.ToString("o")); + var testClass = new DateClass { Id = Guid.NewGuid(), @@ -100,25 +72,6 @@ public async Task can_issue_queries_against_DateTime_with_camel_casing() await session.SaveChangesAsync(); - var cmd = session.Query().Where(x => now >= x.DateTimeField) - .ToCommand(); - - _output.WriteLine(cmd.CommandText); - - var sql = $"select {SchemaName}.mt_immutable_timestamp(d.data ->> \'dateTimeField\') as time from {SchemaName}.mt_doc_dateclass as d"; - - using (var reader = session.Connection.CreateCommand(sql).ExecuteReader()) - { - while (reader.Read()) - { - _output.WriteLine("stored: " + reader.GetDateTime(0).ToString("o")); - } - } - - session.Query().ToList().Each(x => - { - _output.WriteLine(x.DateTimeField.ToString("o")); - }); session.Query() .Count(x => now >= x.DateTimeField).ShouldBe(2); @@ -133,7 +86,7 @@ public async Task can_issue_queries_against_DateTime_with_snake_casing() using (var session = theStore.LightweightSession()) { var now = GenerateTestDateTime(); - _output.WriteLine("now: " + now.ToString("o")); + var testClass = new DateClass { Id = Guid.NewGuid(), @@ -154,25 +107,6 @@ public async Task can_issue_queries_against_DateTime_with_snake_casing() await session.SaveChangesAsync(); - var cmd = session.Query().Where(x => now >= x.DateTimeField) - .ToCommand(); - - _output.WriteLine(cmd.CommandText); - - var sql = $"select {SchemaName}.mt_immutable_timestamp(d.data ->> \'date_time_field\') as time from {SchemaName}.mt_doc_dateclass as d"; - - using (var reader = session.Connection.CreateCommand(sql).ExecuteReader()) - { - while (reader.Read()) - { - _output.WriteLine("stored: " + reader.GetDateTime(0).ToString("o")); - } - } - - session.Query().ToList().Each(x => - { - _output.WriteLine(x.DateTimeField.ToString("o")); - }); session.Query() .Count(x => now >= x.DateTimeField).ShouldBe(2); @@ -187,7 +121,7 @@ public async Task can_issue_queries_against_DateTime_as_duplicated_column() using (var session = theStore.LightweightSession()) { var now = GenerateTestDateTime(); - _output.WriteLine("now: " + now.ToString("o")); + var testClass = new DateClass { Id = Guid.NewGuid(), @@ -208,15 +142,7 @@ public async Task can_issue_queries_against_DateTime_as_duplicated_column() await session.SaveChangesAsync(); - var cmd = session.Query().Where(x => now >= x.DateTimeField) - .ToCommand(); - - _output.WriteLine(cmd.CommandText); - session.Query().ToList().Each(x => - { - _output.WriteLine(x.DateTimeField.ToString("o")); - }); session.Query() .Count(x => now >= x.DateTimeField).ShouldBe(2); @@ -229,7 +155,7 @@ public async Task can_issue_queries_against_the_datetime_offset() using (var session = theStore.LightweightSession()) { var now = GenerateTestDateTimeOffset(); - _output.WriteLine("now: " + now.ToString("o")); + var testClass = new DateOffsetClass { Id = Guid.NewGuid(), @@ -250,15 +176,7 @@ public async Task can_issue_queries_against_the_datetime_offset() await session.SaveChangesAsync(); - var cmd = session.Query().Where(x => now >= x.DateTimeOffsetField) - .ToCommand(); - _output.WriteLine(cmd.CommandText); - - session.Query().ToList().Each(x => - { - _output.WriteLine(x.DateTimeOffsetField.ToString("o")); - }); session.Query() .Count(x => now >= x.DateTimeOffsetField).ShouldBe(2); @@ -273,7 +191,7 @@ public async Task can_issue_queries_against_the_datetime_offset_as_duplicate_fie using (var session = theStore.LightweightSession()) { var now = GenerateTestDateTimeOffset(); - _output.WriteLine("now: " + now.ToString("o")); + var testClass = new DateOffsetClass { Id = Guid.NewGuid(), @@ -294,15 +212,7 @@ public async Task can_issue_queries_against_the_datetime_offset_as_duplicate_fie await session.SaveChangesAsync(); - var cmd = session.Query().Where(x => now >= x.DateTimeOffsetField) - .ToCommand(); - - _output.WriteLine(cmd.CommandText); - session.Query().ToList().Each(x => - { - _output.WriteLine(x.DateTimeOffsetField.ToString("o")); - }); session.Query() .Count(x => now >= x.DateTimeOffsetField).ShouldBe(2); diff --git a/src/LinqTests/Bugs/Bug_503_query_on_null_complex_object.cs b/src/LinqTests/Bugs/Bug_503_query_on_null_complex_object.cs index c1d9e89d54..1bde02be1e 100644 --- a/src/LinqTests/Bugs/Bug_503_query_on_null_complex_object.cs +++ b/src/LinqTests/Bugs/Bug_503_query_on_null_complex_object.cs @@ -3,17 +3,14 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_503_query_on_null_complex_object: IntegrationContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task should_not_blow_up_when_querying_for_null_object() { + await theStore.Advanced.ResetAllData(); using (var sessionOne = theStore.LightweightSession()) { sessionOne.Store(new Target { String = "Something", Inner = new Target(), AnotherString = "first" }); @@ -24,7 +21,6 @@ public async Task should_not_blow_up_when_querying_for_null_object() using (var querySession = theStore.QuerySession()) { - querySession.Logger = new TestOutputMartenLogger(_output); var targets = querySession.Query() .Where(x => x.String == "Something" && x.Inner != null) .ToList(); @@ -34,8 +30,7 @@ public async Task should_not_blow_up_when_querying_for_null_object() } } - public Bug_503_query_on_null_complex_object(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_503_query_on_null_complex_object(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Bugs/Bug_504_Take_Skip_before_Select_not_applying_sort_or_where_clause.cs b/src/LinqTests/Bugs/Bug_504_Take_Skip_before_Select_not_applying_sort_or_where_clause.cs index 57da00d456..5201ee592a 100644 --- a/src/LinqTests/Bugs/Bug_504_Take_Skip_before_Select_not_applying_sort_or_where_clause.cs +++ b/src/LinqTests/Bugs/Bug_504_Take_Skip_before_Select_not_applying_sort_or_where_clause.cs @@ -6,14 +6,11 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_504_Take_Skip_before_Select_not_applying_sort_or_where_clause: IntegrationContext { - private readonly ITestOutputHelper _output; private IEnumerable Make(int count) { @@ -42,8 +39,6 @@ public async Task return_the_correct_number_of_results_when_skip_take_is_after_s QueryStatistics stats; - theSession.Logger = new TestOutputMartenLogger(_output); - var queryable = await theSession.Query() .Stats(out stats) .Where(_ => _.Color == Colors.Blue) @@ -81,8 +76,12 @@ public async Task return_the_correct_number_of_results_when_skip_take_is_before_ queryable.Count.ShouldBe(10); } - public Bug_504_Take_Skip_before_Select_not_applying_sort_or_where_clause(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + + public Bug_504_Take_Skip_before_Select_not_applying_sort_or_where_clause(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Bugs/Bug_561_negation_of_query_on_contains.cs b/src/LinqTests/Bugs/Bug_561_negation_of_query_on_contains.cs index b20384b130..d6af2e12c5 100644 --- a/src/LinqTests/Bugs/Bug_561_negation_of_query_on_contains.cs +++ b/src/LinqTests/Bugs/Bug_561_negation_of_query_on_contains.cs @@ -14,8 +14,9 @@ public Bug_561_negation_of_query_on_contains(DefaultStoreFixture fixture) : base } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); var doc1 = new DocWithArrays { Strings = ["a", "b", "c"] }; var doc2 = new DocWithArrays { Strings = ["c", "d", "e"] }; var doc3 = new DocWithArrays { Strings = ["d", "e", "f"] }; @@ -23,7 +24,7 @@ protected override Task fixtureSetup() theSession.Store(doc1, doc2, doc3, doc4); - return theSession.SaveChangesAsync(); + await theSession.SaveChangesAsync(); } [Fact] diff --git a/src/LinqTests/Bugs/Bug_634_include_against_soft_deleted_docs.cs b/src/LinqTests/Bugs/Bug_634_include_against_soft_deleted_docs.cs index fdef440936..03176af2a4 100644 --- a/src/LinqTests/Bugs/Bug_634_include_against_soft_deleted_docs.cs +++ b/src/LinqTests/Bugs/Bug_634_include_against_soft_deleted_docs.cs @@ -4,17 +4,12 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_634_include_against_soft_deleted_docs: BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_634_include_against_soft_deleted_docs(ITestOutputHelper output) + public Bug_634_include_against_soft_deleted_docs() { - _output = output; StoreOptions(_ => { _.Schema.For().SoftDeleted(); @@ -77,8 +72,6 @@ public async Task include_finds_nothing_when_it_is_soft_deleted() using (var query = theStore.QuerySession()) { - query.Logger = new TestOutputMartenLogger(_output); - User expected = null; var issues = query.Query() diff --git a/src/LinqTests/Bugs/Bug_784_Collection_Contains_within_compiled_query.cs b/src/LinqTests/Bugs/Bug_784_Collection_Contains_within_compiled_query.cs index b78ec56533..dbc65a9e68 100644 --- a/src/LinqTests/Bugs/Bug_784_Collection_Contains_within_compiled_query.cs +++ b/src/LinqTests/Bugs/Bug_784_Collection_Contains_within_compiled_query.cs @@ -7,17 +7,15 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_784_Collection_Contains_within_compiled_query : IntegrationContext { - private readonly ITestOutputHelper _output; [Fact] public async Task do_not_blow_up_with_exceptions() { + await theStore.Advanced.ResetAllData(); // Test failure bomb if (DateTime.Today < new DateTime(2023, 9, 12)) return; @@ -34,8 +32,6 @@ public async Task do_not_blow_up_with_exceptions() await theStore.BulkInsertAsync(targets); await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); - var expected = targets.Where(x => x.Flag && x.NumberArray.Contains(5)).ToArray(); expected.Any(x => x.Id == targets[1].Id).ShouldBeTrue(); expected.Any(x => x.Id == targets[5].Id).ShouldBeTrue(); @@ -62,8 +58,7 @@ public Expression, IEnumerable>> QueryIs() public int Number { get; set; } } - public Bug_784_Collection_Contains_within_compiled_query(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_784_Collection_Contains_within_compiled_query(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Bugs/Bug_834_querying_inside_of_child_collections.cs b/src/LinqTests/Bugs/Bug_834_querying_inside_of_child_collections.cs index 126c56f3a2..302a8b596c 100644 --- a/src/LinqTests/Bugs/Bug_834_querying_inside_of_child_collections.cs +++ b/src/LinqTests/Bugs/Bug_834_querying_inside_of_child_collections.cs @@ -4,17 +4,12 @@ using System.Threading.Tasks; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_834_querying_inside_of_child_collections : IntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_834_querying_inside_of_child_collections(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public Bug_834_querying_inside_of_child_collections(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } public class Contact { @@ -31,7 +26,6 @@ public async Task can_query_with_condition_within_any() await theStore.BulkInsertAsync(new Contact[]{c1, c2, c3}); - theSession.Logger = new TestOutputMartenLogger(_output); theSession.Query().Where(x => x.Tags.Any(t => t.StartsWith("A"))).Any() .ShouldBeTrue(); diff --git a/src/LinqTests/Bugs/Bug_using_literal_false_in_where_clause.cs b/src/LinqTests/Bugs/Bug_using_literal_false_in_where_clause.cs index 4d94194330..95a12ed99d 100644 --- a/src/LinqTests/Bugs/Bug_using_literal_false_in_where_clause.cs +++ b/src/LinqTests/Bugs/Bug_using_literal_false_in_where_clause.cs @@ -5,18 +5,10 @@ using Marten.Metadata; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class Bug_using_literal_false_in_where_clause : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_using_literal_false_in_where_clause(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task query_soft_deleted_and_false() @@ -61,8 +53,6 @@ public async Task return_correct_results() theSession.Store(aggregate2); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - IQueryable query = this.theSession.Query(); query = query.Where(x => !x.Deleted); query = query.Where(x => false); diff --git a/src/LinqTests/Bugs/child_parent_inclusion_bug.cs b/src/LinqTests/Bugs/child_parent_inclusion_bug.cs index b9f8103811..c7e3e5aadd 100644 --- a/src/LinqTests/Bugs/child_parent_inclusion_bug.cs +++ b/src/LinqTests/Bugs/child_parent_inclusion_bug.cs @@ -6,18 +6,10 @@ using Marten.Schema; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Bugs; public class child_parent_inclusion_bug : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public child_parent_inclusion_bug(ITestOutputHelper output) - { - _output = output; - } [Fact] public async Task WhereStatementIsRespectedWhenIncludingParent() @@ -45,8 +37,6 @@ public async Task WhereStatementIsRespectedWhenIncludingParent() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var parents = new Dictionary(); var items = await theSession.Query() diff --git a/src/LinqTests/Bugs/compiled_query_problem_with_includes_and_ICompiledQuery_reuse.cs b/src/LinqTests/Bugs/compiled_query_problem_with_includes_and_ICompiledQuery_reuse.cs index 2f2bd7dd90..6904a22a4a 100644 --- a/src/LinqTests/Bugs/compiled_query_problem_with_includes_and_ICompiledQuery_reuse.cs +++ b/src/LinqTests/Bugs/compiled_query_problem_with_includes_and_ICompiledQuery_reuse.cs @@ -17,6 +17,11 @@ public compiled_query_problem_with_includes_and_ICompiledQuery_reuse(DefaultStor { } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public class IssueWithUsers: ICompiledListQuery { public List Users { get; } = new List(); diff --git a/src/LinqTests/Bugs/compiled_query_problem_with_nested_properties.cs b/src/LinqTests/Bugs/compiled_query_problem_with_nested_properties.cs index 82843de703..be2b6151d3 100644 --- a/src/LinqTests/Bugs/compiled_query_problem_with_nested_properties.cs +++ b/src/LinqTests/Bugs/compiled_query_problem_with_nested_properties.cs @@ -15,6 +15,7 @@ public class compiled_query_problem_with_nested_properties: IntegrationContext [Fact] public async Task can_do_a_compiled_query_on_nested_property() { + await theStore.Advanced.ResetAllData(); var targets = Target.GenerateRandomData(100).ToArray(); await theStore.BulkInsertAsync(targets); diff --git a/src/LinqTests/Bugs/query_with_order_by.cs b/src/LinqTests/Bugs/query_with_order_by.cs index f510313b3a..47ddd434fc 100644 --- a/src/LinqTests/Bugs/query_with_order_by.cs +++ b/src/LinqTests/Bugs/query_with_order_by.cs @@ -14,6 +14,11 @@ public query_with_order_by(DefaultStoreFixture fixture): base(fixture) { } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + [Fact] public async Task query_with_order_by_for_string_property_with_comparer() { diff --git a/src/LinqTests/ChildCollections/count_for_child_collections.cs b/src/LinqTests/ChildCollections/count_for_child_collections.cs index 9421a2ab26..b46260ebde 100644 --- a/src/LinqTests/ChildCollections/count_for_child_collections.cs +++ b/src/LinqTests/ChildCollections/count_for_child_collections.cs @@ -7,14 +7,10 @@ using Marten.Linq; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.ChildCollections; public class count_for_child_collections : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task GivenTwoLevelsOfChildCollections_WhenCountCalled_ThenReturnsProperCount() { @@ -22,7 +18,7 @@ public async Task GivenTwoLevelsOfChildCollections_WhenCountCalled_ThenReturnsPr await SetupTestData(); - theSession.Logger = new TestOutputMartenLogger(_output); + var result = theSession .Query() @@ -39,7 +35,7 @@ public async Task two_levels_of_child_collections_in_compiled_query() await SetupTestData(); - theSession.Logger = new TestOutputMartenLogger(_output); + var result = await theSession .Query() @@ -141,8 +137,7 @@ private async Task SetupTestData() await theSession.SaveChangesAsync(); } - public count_for_child_collections(ITestOutputHelper output) + public count_for_child_collections() { - _output = output; } } diff --git a/src/LinqTests/ChildCollections/query_against_child_collections.cs b/src/LinqTests/ChildCollections/query_against_child_collections.cs index 2b886eed08..edf3af5aa4 100644 --- a/src/LinqTests/ChildCollections/query_against_child_collections.cs +++ b/src/LinqTests/ChildCollections/query_against_child_collections.cs @@ -11,17 +11,12 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; - namespace LinqTests.ChildCollections; public class query_against_child_collections: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public query_against_child_collections(ITestOutputHelper output) + public query_against_child_collections() { - _output = output; StoreOptions(_ => _.UseSystemTextJsonForSerialization(EnumStorage.AsString)); } @@ -118,7 +113,7 @@ public async Task can_query_with_an_any_operator() { await buildUpTargetData(); - theSession.Logger = new TestOutputMartenLogger(_output); + #region sample_any-query-through-child-collections @@ -139,7 +134,7 @@ public async Task can_query_with_an_any_operator_and_string_NotIsNullOrEmpty() { await buildUpTargetData(); - theSession.Logger = new TestOutputMartenLogger(_output); + var results = theSession.Query() .Where(x => x.Children.Any(c => !string.IsNullOrEmpty(c.NullableString))) @@ -156,7 +151,7 @@ public async Task can_query_with_an_any_operator_and_string_IsNullOrWhitespace() { await buildUpTargetData(); - theSession.Logger = new TestOutputMartenLogger(_output); + var results = theSession.Query() .Where(x => x.Children.Any(c => string.IsNullOrWhiteSpace(c.NullableString))) @@ -173,7 +168,7 @@ public async Task can_query_with_an_any_operator_that_does_a_multiple_search_wit { await buildUpTargetData(); - theSession.Logger = new TestOutputMartenLogger(_output); + #region sample_any-query-through-child-collection-with-and @@ -245,8 +240,6 @@ public async Task Bug_503_child_collection_query_in_compiled_query() using (var session2 = theStore.LightweightSession()) { - session2.Logger = new TestOutputMartenLogger(_output); - // This works var o1 = session2.Query().First(o => o.Inners.Any(i => i.Type == "T1" && i.Value == "V12")); o1.ShouldNotBeNull(); @@ -567,7 +560,7 @@ public async Task query_against_string_array_with_Length() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Query().Where(x => x.Strings.Length == 4).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc3.Id); @@ -647,7 +640,7 @@ public async Task query_against_number_list_with_any() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Query().Where(x => x.Numbers.Any(_ => _ == 3)).ToArray() .Select(x => x.Id).ShouldHaveTheSameElementsAs(doc1.Id, doc2.Id); @@ -674,7 +667,7 @@ public async Task query_against_number_list_with_count_method() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Query() .Single(x => x.Numbers.Count() == 4).Id.ShouldBe(doc3.Id); diff --git a/src/LinqTests/ChildCollections/query_with_inner_query_with_CollectionToArrayJsonConverter_onProperty.cs b/src/LinqTests/ChildCollections/query_with_inner_query_with_CollectionToArrayJsonConverter_onProperty.cs index e0e31515ac..71c3c0e21f 100644 --- a/src/LinqTests/ChildCollections/query_with_inner_query_with_CollectionToArrayJsonConverter_onProperty.cs +++ b/src/LinqTests/ChildCollections/query_with_inner_query_with_CollectionToArrayJsonConverter_onProperty.cs @@ -8,7 +8,7 @@ using Marten.Testing.Harness; using Newtonsoft.Json; using Shouldly; -using Xunit.Abstractions; + namespace LinqTests.ChildCollections; @@ -75,8 +75,6 @@ public static TypeWithInnerCollectionsWithJsonConverterAttribute Create(params s public class query_with_inner_query_with_CollectionToArrayJsonConverter_onProperty : IntegrationContext { - private readonly ITestOutputHelper _output; - private static readonly TypeWithInnerCollectionsWithJsonConverterAttribute[] TestData = [ TypeWithInnerCollectionsWithJsonConverterAttribute.Create("one", "two"), @@ -112,7 +110,6 @@ public async Task having_type_with_CollectionToArrayJsonConverter_can_query_agai } await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); var results = await query.Query() .Where(predicate) .ToListAsync(); @@ -121,8 +118,7 @@ public async Task having_type_with_CollectionToArrayJsonConverter_can_query_agai results.All(e => e.Enumerable.Contains(SearchPhrase)).ShouldBeTrue(); } - public query_with_inner_query_with_CollectionToArrayJsonConverter_onProperty(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public query_with_inner_query_with_CollectionToArrayJsonConverter_onProperty(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/ChildCollections/querying_through_n_deep_sub_collections.cs b/src/LinqTests/ChildCollections/querying_through_n_deep_sub_collections.cs index 67c73b9acb..b62f963ae5 100644 --- a/src/LinqTests/ChildCollections/querying_through_n_deep_sub_collections.cs +++ b/src/LinqTests/ChildCollections/querying_through_n_deep_sub_collections.cs @@ -9,14 +9,10 @@ using Shouldly; using Weasel.Core; using Weasel.Postgresql; -using Xunit.Abstractions; - namespace LinqTests.ChildCollections; public class querying_through_n_deep_sub_collections : IntegrationContext { - private readonly ITestOutputHelper _output; - public class Top { public Guid Id { get; set; } @@ -79,20 +75,19 @@ public class Bottom private readonly Top top6 = new Top().WithMiddle(Colors.Green, "Jake"); private readonly Top topNoBottoms = new Top().WithMiddle(Colors.Blue); - public querying_through_n_deep_sub_collections(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public querying_through_n_deep_sub_collections(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { - return theStore.BulkInsertAsync(new Top[]{blueBill, top2, top3, greenBill, top5, top6, topNoBottoms}); + await theStore.Advanced.ResetAllData(); + await theStore.BulkInsertAsync(new Top[]{blueBill, top2, top3, greenBill, top5, top6, topNoBottoms}); } [Fact] public async Task can_query_by_any() { - theSession.Logger = new TestOutputMartenLogger(_output); var results = await theSession.Query() // This is trying to filter on a child collection of a child collection @@ -107,7 +102,6 @@ public async Task can_query_by_any() [Fact] public void query_inside_of_child_collections_collection() { - theSession.Logger = new TestOutputMartenLogger(_output); var results = theSession.Query().Where(x => x.Middles.Any(m => m.Color == Colors.Green && m.Bottoms.Any(b => b.Name == "Bill"))); diff --git a/src/LinqTests/Compiled/compiled_queries.cs b/src/LinqTests/Compiled/compiled_queries.cs index 1c9bbde11a..2d4e93a172 100644 --- a/src/LinqTests/Compiled/compiled_queries.cs +++ b/src/LinqTests/Compiled/compiled_queries.cs @@ -10,7 +10,7 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; + namespace LinqTests.Compiled; @@ -23,15 +23,16 @@ public compiled_queries(DefaultStoreFixture fixture): base(fixture) { } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); _user1 = new User { FirstName = "Jeremy", UserName = "jdm", LastName = "Miller" }; var user2 = new User { FirstName = "Jens" }; var user3 = new User { FirstName = "Jeff" }; var user4 = new User { FirstName = "Corey", UserName = "myusername", LastName = "Kaylor" }; _user5 = new User { FirstName = "Jeremy", UserName = "shadetreedev", LastName = "Miller" }; - return theStore.BulkInsertDocumentsAsync(new[] { _user1, user2, user3, user4, _user5 }); + await theStore.BulkInsertDocumentsAsync(new[] { _user1, user2, user3, user4, _user5 }); } #region sample_using_QueryStatistics_with_compiled_query @@ -465,11 +466,8 @@ public Expression, TUser>> QueryIs() public class when_compiled_queries_are_used_in_multi_tenancy: OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - - public when_compiled_queries_are_used_in_multi_tenancy(ITestOutputHelper output) + public when_compiled_queries_are_used_in_multi_tenancy() { - _output = output; } [Fact] @@ -499,7 +497,6 @@ public async Task compile_query_honors_the_current_tenant() } await using var query = theStore.QuerySession("one"); - query.Logger = new TestOutputMartenLogger(_output); var user = await query.QueryAsync(new UserByUsernameWithFields { UserName = "han" }); user.Id.ShouldBe(hanOne.Id); diff --git a/src/LinqTests/Compiled/compiled_query_by_string_fragments.cs b/src/LinqTests/Compiled/compiled_query_by_string_fragments.cs index e5d8041c90..f568968b18 100644 --- a/src/LinqTests/Compiled/compiled_query_by_string_fragments.cs +++ b/src/LinqTests/Compiled/compiled_query_by_string_fragments.cs @@ -7,22 +7,19 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Compiled; public class compiled_query_by_string_fragments : IntegrationContext { - private readonly ITestOutputHelper _output; - - public compiled_query_by_string_fragments(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public compiled_query_by_string_fragments(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] public async Task can_use_starts_with() { + await theStore.Advanced.ResetAllData(); + var user1 = new User { UserName = "Sir Gawain" @@ -71,8 +68,6 @@ public async Task can_use_ends_with() theSession.Store(user1, user2, user3, user4, user5); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var users = await theSession.QueryAsync(new UserNameEndsWith()); users.Single().UserName.ShouldBe("Gary Clark Jr"); } @@ -123,6 +118,8 @@ public Expression, IEnumerable>> QueryIs() [Fact] public async Task can_use_string_contains_case_insensitive() { + await theStore.Advanced.ResetAllData(); + var user1 = new User { UserName = "Sir Gawain" diff --git a/src/LinqTests/Includes/end_to_end_query_with_compiled_include.cs b/src/LinqTests/Includes/end_to_end_query_with_compiled_include.cs index e167d38252..f412d5ef1d 100644 --- a/src/LinqTests/Includes/end_to_end_query_with_compiled_include.cs +++ b/src/LinqTests/Includes/end_to_end_query_with_compiled_include.cs @@ -6,7 +6,6 @@ using Marten.Linq; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; using Issue = Marten.Testing.Documents.Issue; using User = Marten.Testing.Documents.User; @@ -14,8 +13,6 @@ namespace LinqTests.Includes; public class end_to_end_query_with_compiled_include_Tests: IntegrationContext { - private readonly ITestOutputHelper _output; - #region sample_compiled_include [Fact] @@ -85,7 +82,6 @@ public async Task compiled_include_to_list() using var querySession = theStore.QuerySession(); var compiledQuery = new IssueWithUsers(); - querySession.Logger = new TestOutputMartenLogger(_output); var issues = await querySession.QueryAsync(compiledQuery); compiledQuery.Users.Count.ShouldBe(2); @@ -140,9 +136,13 @@ public async Task compiled_include_to_dictionary() #endregion - public end_to_end_query_with_compiled_include_Tests(DefaultStoreFixture fixture, ITestOutputHelper output): + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + + public end_to_end_query_with_compiled_include_Tests(DefaultStoreFixture fixture): base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Includes/end_to_end_query_with_include.cs b/src/LinqTests/Includes/end_to_end_query_with_include.cs index ffb0e6f339..1fb4050f80 100644 --- a/src/LinqTests/Includes/end_to_end_query_with_include.cs +++ b/src/LinqTests/Includes/end_to_end_query_with_include.cs @@ -7,7 +7,6 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; using Issue = Marten.Testing.Documents.Issue; using User = Marten.Testing.Documents.User; using Classroom = LinqTests.Includes.includes_with_custom_mapping.Classroom; @@ -17,11 +16,10 @@ namespace LinqTests.Includes; public class end_to_end_query_with_include: IntegrationContext { - private readonly ITestOutputHelper _output; - - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { - return theStore.Advanced.Clean.DeleteAllDocumentsAsync(); + await theStore.Advanced.ResetAllData(); + await theStore.Advanced.Clean.DeleteAllDocumentsAsync(); } [Fact] @@ -95,7 +93,7 @@ public async Task simple_include_for_a_single_document() await session.SaveChangesAsync(); using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + User included = null; var issue2 = query @@ -530,7 +528,7 @@ public async Task include_to_dictionary_with_select() using var query = theStore.QuerySession(); var dict = new Dictionary(); - query.Logger = new TestOutputMartenLogger(_output); + var ids = query.Query().Include(dict).On(x => x.AssigneeId) .Where(x => x.Status == "Done") @@ -615,7 +613,7 @@ public async Task simple_include_for_a_single_document_async() await session.SaveChangesAsync(); await using var query = theStore.QuerySession(); - query.Logger = new TestOutputMartenLogger(_output); + User included = null; var issue2 = await query.Query() .Include(x => x.AssigneeId, x => included = x) @@ -646,7 +644,7 @@ public async Task include_to_list_async() await using var query = theStore.QuerySession(); var list = new List(); - query.Logger = new TestOutputMartenLogger(_output); + await query.Query().Include(x => x.AssigneeId, list).ToListAsync(); list.Count.ShouldBe(2); @@ -756,7 +754,7 @@ public async Task multiple_includes() User assignee2 = null; User reporter2 = null; - query.Logger = new TestOutputMartenLogger(_output); + query .Query() .Include(x => assignee2 = x).On(x => x.AssigneeId) @@ -795,7 +793,7 @@ public async Task include_many_to_list() using (var query = theStore.QuerySession()) { - query.Logger = new TestOutputMartenLogger(_output); + var list = new List(); @@ -851,7 +849,7 @@ public class IssueDTO public async Task Bug_1715_simple_include_for_a_single_document_async() { await using var session = theStore.IdentitySession(); - session.Logger = new TestOutputMartenLogger(_output); + var user = new User(); var bug = new Bug(); @@ -923,7 +921,7 @@ public async Task include_many_to_list_with_empty_parent_collection() using (var query = theStore.QuerySession()) { - query.Logger = new TestOutputMartenLogger(_output); + var list = new List(); @@ -1005,9 +1003,8 @@ public async Task include_to_dictionary_list() #endregion #nullable restore - public end_to_end_query_with_include(ITestOutputHelper output, DefaultStoreFixture fixture) : base(fixture) + public end_to_end_query_with_include(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Includes/includes_with_custom_mapping.cs b/src/LinqTests/Includes/includes_with_custom_mapping.cs index aee3e72c4d..f81e62d052 100644 --- a/src/LinqTests/Includes/includes_with_custom_mapping.cs +++ b/src/LinqTests/Includes/includes_with_custom_mapping.cs @@ -3,24 +3,19 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using JasperFx.Core; using Marten; -using Marten.Linq; using Marten.Schema; +using JasperFx.Core; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Includes; public class includes_with_custom_mapping : IntegrationContext { - private readonly ITestOutputHelper _testOutputHelper; private const string TenantId = "the_tenant_id"; - public includes_with_custom_mapping(DefaultStoreFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) + public includes_with_custom_mapping(DefaultStoreFixture fixture) : base(fixture) { - _testOutputHelper = testOutputHelper; } protected override async Task fixtureSetup() @@ -62,7 +57,6 @@ public async Task include_for_a_single_mapped_document_int_one_to_one() .Include(u => teacher = u).On(r => r.TeacherId, u => u.StaffId) .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classRoom = await query.SingleAsync(); @@ -83,7 +77,6 @@ public async Task include_for_a_single_mapped_document_string_one_to_one() .Include(c => homeRoom = c).On(u => u.HomeRoom, c => c.RoomCode) .Where(u => u.Name == "Student-1002"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -103,7 +96,6 @@ public async Task include_for_a_single_mapped_document_one_to_many_list() .Include(students).On(r => r.RoomCode, u => u.HomeRoom) .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -123,7 +115,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_list() .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -144,7 +135,6 @@ public async Task include_for_multiple_mapped_document_many_to_one_list() .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -165,7 +155,6 @@ public async Task include_for_multiple_mapped_document_string_many_to_one_dictio .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -185,7 +174,6 @@ public async Task include_for_multiple_mapped_document_int_many_to_one_dictionar .Query() .Include(teachers).On(r => r.TeacherId, u => u.StaffId); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -205,7 +193,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_dictionary() .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom); - LogCommand(query); var classRoom = await query.ToListAsync(); @@ -233,7 +220,6 @@ public async Task include_for_a_single_mapped_document_int_one_to_one_filtered() .Include(u => teacher = u).On(r => r.TeacherId, u => u.StaffId, u => u.Name == "Invalid") .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classRoom = await query.SingleAsync(); @@ -252,7 +238,6 @@ public async Task include_for_a_single_mapped_document_string_one_to_one_filtere .On(u => u.HomeRoom, c => c.RoomCode, c => c.RoomCode == "Invalid") .Where(u => u.Name == "Student-1002"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -270,7 +255,6 @@ public async Task include_for_a_single_mapped_document_one_to_many_list_filtered .Include(students).On(r => r.RoomCode, u => u.HomeRoom, u => u.Name.EndsWith("1")) .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -290,7 +274,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_list_filtered .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom, u => u.Name.EndsWith("1")); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -311,7 +294,6 @@ public async Task include_for_multiple_mapped_document_many_to_one_list_filtered .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode, r => r.TeacherId < 13) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -332,7 +314,6 @@ public async Task include_for_multiple_mapped_document_string_many_to_one_dictio .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode, r => r.TeacherId < 13) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -352,7 +333,6 @@ public async Task include_for_multiple_mapped_document_int_many_to_one_dictionar .Query() .Include(teachers).On(r => r.TeacherId, u => u.StaffId, u => u.StaffId < 13); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -372,7 +352,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_dictionary_fi .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom, u => u.Name.EndsWith("1")); - LogCommand(query); var classRoom = await query.ToListAsync(); @@ -400,7 +379,6 @@ public async Task include_for_a_single_mapped_document_int_one_to_one_duplicate_ .Include(u => teacher = u).On(r => r.TeacherId, u => u.StaffId) .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classRoom = await query.SingleAsync(); @@ -421,7 +399,6 @@ public async Task include_for_a_single_mapped_document_string_one_to_one_duplica .Include(c => homeRoom = c).On(u => u.HomeRoom, c => c.RoomCode) .Where(u => u.Name == "Student-1002"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -441,7 +418,6 @@ public async Task include_for_a_single_mapped_document_one_to_many_list_duplicat .Include(students).On(r => r.RoomCode, u => u.HomeRoom) .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -461,7 +437,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_list_duplicat .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -482,7 +457,6 @@ public async Task include_for_multiple_mapped_document_many_to_one_list_duplicat .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -503,7 +477,6 @@ public async Task include_for_multiple_mapped_document_string_many_to_one_dictio .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -523,7 +496,6 @@ public async Task include_for_multiple_mapped_document_int_many_to_one_dictionar .Query() .Include(teachers).On(r => r.TeacherId, u => u.StaffId); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -543,7 +515,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_dictionary_du .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom); - LogCommand(query); var classRoom = await query.ToListAsync(); @@ -571,7 +542,6 @@ public async Task include_for_a_single_mapped_document_int_one_to_one_filtered_d .Include(u => teacher = u).On(r => r.TeacherId, u => u.StaffId, u => u.Name == "Invalid") .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classRoom = await query.SingleAsync(); @@ -590,7 +560,6 @@ public async Task include_for_a_single_mapped_document_string_one_to_one_filtere .On(u => u.HomeRoom, c => c.RoomCode, c => c.RoomCode == "Invalid") .Where(u => u.Name == "Student-1002"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -608,7 +577,6 @@ public async Task include_for_a_single_mapped_document_one_to_many_list_filtered .Include(students).On(r => r.RoomCode, u => u.HomeRoom, u => u.Name.EndsWith("1")) .Where(r => r.RoomCode == "AA-1"); - LogCommand(query, FetchType.FetchOne); var classroom = await query.SingleAsync(); @@ -628,7 +596,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_list_filtered .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom, u => u.Name.EndsWith("1")); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -649,7 +616,6 @@ public async Task include_for_multiple_mapped_document_many_to_one_list_filtered .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode, r => r.TeacherId < 13) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -670,7 +636,6 @@ public async Task include_for_multiple_mapped_document_string_many_to_one_dictio .Include(homeRooms).On(u => u.HomeRoom, r => r.RoomCode, r => r.TeacherId < 13) .Where(s => s.StaffId == null); - LogCommand(query); var students = await query.ToListAsync(); @@ -690,7 +655,6 @@ public async Task include_for_multiple_mapped_document_int_many_to_one_dictionar .Query() .Include(teachers).On(r => r.TeacherId, u => u.StaffId, u => u.StaffId < 13); - LogCommand(query); var classrooms = await query.ToListAsync(); @@ -710,7 +674,6 @@ public async Task include_for_multiple_mapped_document_one_to_many_dictionary_fi .Query() .Include(students).On(r => r.RoomCode, u => u.HomeRoom, u => u.Name.EndsWith("1")); - LogCommand(query); var classRoom = await query.ToListAsync(); @@ -770,19 +733,6 @@ public async Task batch_query_mapped_includes() (await query3).ShouldNotBeNull().Count.ShouldBe(5); } - /// - /// Easy preview of the sql query - /// - private void LogCommand(IQueryable queryable, FetchType fetchType = FetchType.FetchMany) - { - var command = queryable.ToCommand(fetchType); - - _testOutputHelper.WriteLine( - "{0}\nParameters:\n{1}", - command.CommandText.Replace(";", "; \n"), - command.Parameters.Select(p => $" {p.ParameterName}: {p.NpgsqlValue}").Join("\n")); - } - #region Test Models // alias is to avoid long name issues diff --git a/src/LinqTests/Includes/includes_with_filtering_on_included_documents.cs b/src/LinqTests/Includes/includes_with_filtering_on_included_documents.cs index da2adb194f..c3c71326bd 100644 --- a/src/LinqTests/Includes/includes_with_filtering_on_included_documents.cs +++ b/src/LinqTests/Includes/includes_with_filtering_on_included_documents.cs @@ -22,6 +22,7 @@ public includes_with_filtering_on_included_documents(DefaultStoreFixture fixture protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Target)); await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(TargetHolder)); diff --git a/src/LinqTests/Internals/BoolNotVisitorTests.cs b/src/LinqTests/Internals/BoolNotVisitorTests.cs index 4dc03d5bbd..7a4d9bd274 100644 --- a/src/LinqTests/Internals/BoolNotVisitorTests.cs +++ b/src/LinqTests/Internals/BoolNotVisitorTests.cs @@ -3,14 +3,10 @@ using System.Threading.Tasks; using Marten.Services; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests.Internals; public class BoolNotVisitorTests : OneOffConfigurationsContext { - private readonly ITestOutputHelper _output; - public class TestClass { public TestClass() @@ -63,8 +59,7 @@ public async Task when_doc_with_bool_false_with_serializer_default_value_handlin } } - public BoolNotVisitorTests(ITestOutputHelper output) + public BoolNotVisitorTests() { - _output = output; } } diff --git a/src/LinqTests/Operators/aggregate_functions.cs b/src/LinqTests/Operators/aggregate_functions.cs index 093c848646..7e5940981d 100644 --- a/src/LinqTests/Operators/aggregate_functions.cs +++ b/src/LinqTests/Operators/aggregate_functions.cs @@ -229,6 +229,11 @@ public async Task get_sum_of_integers_with_where_with_nullable_enum(EnumStorage } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public aggregate_functions(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/all_operator.cs b/src/LinqTests/Operators/all_operator.cs index ecede1b139..4edd63e5fe 100644 --- a/src/LinqTests/Operators/all_operator.cs +++ b/src/LinqTests/Operators/all_operator.cs @@ -5,15 +5,17 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Operators; public class all_operator: IntegrationContext { - public all_operator(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public all_operator(DefaultStoreFixture fixture) : base(fixture) + { + } + + protected override async Task fixtureSetup() { - theSession.Logger = new TestOutputMartenLogger(output); + await theStore.Advanced.ResetAllData(); } [Fact] diff --git a/src/LinqTests/Operators/any_operator.cs b/src/LinqTests/Operators/any_operator.cs index e0c6648224..e29d7d2d6f 100644 --- a/src/LinqTests/Operators/any_operator.cs +++ b/src/LinqTests/Operators/any_operator.cs @@ -138,6 +138,11 @@ public async Task any_hit_with_more_than_one_match_async() result.ShouldBeTrue(); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public any_operator(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/async_enumerable.cs b/src/LinqTests/Operators/async_enumerable.cs index 21067bea7f..30a8153689 100644 --- a/src/LinqTests/Operators/async_enumerable.cs +++ b/src/LinqTests/Operators/async_enumerable.cs @@ -15,6 +15,11 @@ public AsyncEnumerable(DefaultStoreFixture fixture) : base(fixture) { } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + #region sample_query_to_async_enumerable [Fact] diff --git a/src/LinqTests/Operators/count_operator.cs b/src/LinqTests/Operators/count_operator.cs index f68eb536c0..874178f3da 100644 --- a/src/LinqTests/Operators/count_operator.cs +++ b/src/LinqTests/Operators/count_operator.cs @@ -185,6 +185,11 @@ public async Task long_count_with_a_where_clause_async() result.ShouldBe(3); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public count_operator(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/distinct_operator.cs b/src/LinqTests/Operators/distinct_operator.cs index b20c478fac..777a281a22 100644 --- a/src/LinqTests/Operators/distinct_operator.cs +++ b/src/LinqTests/Operators/distinct_operator.cs @@ -5,14 +5,10 @@ using Marten.Testing.Harness; using Shouldly; using Weasel.Core; -using Xunit.Abstractions; - namespace LinqTests.Operators; public class distinct_operator : IntegrationContext { - private readonly ITestOutputHelper _output; - [Fact] public async Task get_distinct_number() { @@ -25,7 +21,7 @@ public async Task get_distinct_number() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var queryable = theSession.Query().Select(x => x.Number).Distinct(); queryable.ToList().Count.ShouldBe(3); @@ -86,7 +82,7 @@ public async Task get_distinct_strings() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var queryable = theSession.Query().Select(x => new { x.String, @@ -108,7 +104,7 @@ public async Task get_distinct_enums() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var queryable = theSession.Query().Select(x => x.Color).Distinct(); queryable.ToList().Count.ShouldBe(4); @@ -127,7 +123,7 @@ public async Task get_distinct_nullable_enums() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var queryable = theSession.Query() .Select(x => x.NullableEnum).Distinct(); @@ -151,15 +147,19 @@ public async Task get_distinct_nullable_string_enums() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var queryable = theSession.Query() .Select(x => x.NullableEnum).Distinct(); queryable.ToList().Count.ShouldBe(5); } - public distinct_operator(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + + public distinct_operator(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Operators/first_operator.cs b/src/LinqTests/Operators/first_operator.cs index c42c8464c7..9fdd74e10a 100644 --- a/src/LinqTests/Operators/first_operator.cs +++ b/src/LinqTests/Operators/first_operator.cs @@ -7,15 +7,10 @@ using Marten.Testing.Harness; using Microsoft.Extensions.Logging; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Operators; public class first_operator: IntegrationContext { - private readonly ITestOutputHelper _output; - - [Fact] public async Task first_hit_with_only_one_document() { @@ -43,7 +38,7 @@ public async Task first_or_default_hit_with_only_one_document() [Fact] public async Task first_or_default_miss() { - theSession.Logger = new TestOutputMartenLogger(_output); + theSession.Store(new Target { Number = 1 }); theSession.Store(new Target { Number = 2 }); @@ -169,7 +164,7 @@ public async Task first_or_default_correct_hit_with_more_than_one_match_async_in theSession.Store(new Target { Number = 4 }); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var target = await theSession.Query().Where(x => x.Number == 2).OrderByDescending(x => x.AnotherNumber).FirstOrDefaultAsync(); target.String.ShouldBe("Correct"); @@ -184,7 +179,7 @@ public async Task first_or_default_correct_hit_with_more_than_one_match_async_in theSession.Store(new Target { Number = 4 }); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); + var target = await theSession.Query().OrderByDescending(x => x.AnotherNumber).FirstOrDefaultAsync(x => x.Number == 2, CancellationToken.None); target.String.ShouldBe("Correct"); @@ -205,8 +200,12 @@ await Should.ThrowAsync(async () => }); } - public first_operator(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + + public first_operator(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Operators/is_empty_operator.cs b/src/LinqTests/Operators/is_empty_operator.cs index eb35aa09d6..494fe63c2d 100644 --- a/src/LinqTests/Operators/is_empty_operator.cs +++ b/src/LinqTests/Operators/is_empty_operator.cs @@ -35,6 +35,11 @@ public async Task use_is_empty() } } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public is_empty_operator(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/is_one_of_operator.cs b/src/LinqTests/Operators/is_one_of_operator.cs index 0df620ad80..2ca33150ae 100644 --- a/src/LinqTests/Operators/is_one_of_operator.cs +++ b/src/LinqTests/Operators/is_one_of_operator.cs @@ -9,14 +9,10 @@ using Marten.Testing.Harness; using Microsoft.FSharp.Core; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Operators; public class is_one_of_operator: IntegrationContext { - private readonly ITestOutputHelper _output; - public static TheoryData>>> SupportedIsOneOfWithIntArray = new() { @@ -309,9 +305,8 @@ Func select - public is_one_of_operator(DefaultStoreFixture fixture, ITestOutputHelper output): base(fixture) + public is_one_of_operator(DefaultStoreFixture fixture): base(fixture) { - _output = output; StoreOptions(_ => { //_.Logger(new ConsoleMartenLogger()); diff --git a/src/LinqTests/Operators/is_subset_of_operator.cs b/src/LinqTests/Operators/is_subset_of_operator.cs index e7a933da9f..423da0bbde 100644 --- a/src/LinqTests/Operators/is_subset_of_operator.cs +++ b/src/LinqTests/Operators/is_subset_of_operator.cs @@ -5,21 +5,17 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Operators; public class is_subset_of_operator : IntegrationContext { - private readonly ITestOutputHelper _output; - - public is_subset_of_operator(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public is_subset_of_operator(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); _allTargets = [ CreateTarget("c#"), @@ -30,7 +26,7 @@ protected override Task fixtureSetup() CreateTarget("sql", "mssql"), CreateTarget(".net", "json", "mssql", "c#") ]; - return theStore.BulkInsertAsync(_allTargets); + await theStore.BulkInsertAsync(_allTargets); } public void is_subset_of_example() @@ -80,8 +76,6 @@ public void Can_query_by_hashset() // given var tags = new[] {"c#", "mssql"}; - theSession.Logger = new TestOutputMartenLogger(_output); - /* * CURRENT: select d.id, d.data from public.mt_doc_target as d where CAST(d.data ->> 'tags' as jsonb) <@ :p0 diff --git a/src/LinqTests/Operators/is_super_set_of_operator.cs b/src/LinqTests/Operators/is_super_set_of_operator.cs index c0b6f173a9..a0b35c86f6 100644 --- a/src/LinqTests/Operators/is_super_set_of_operator.cs +++ b/src/LinqTests/Operators/is_super_set_of_operator.cs @@ -28,8 +28,9 @@ public is_super_set_of_operator(DefaultStoreFixture fixture) : base(fixture) } - protected override Task fixtureSetup() + protected override async Task fixtureSetup() { + await theStore.Advanced.ResetAllData(); _allTargets = [ CreateTarget("c#"), @@ -40,7 +41,7 @@ protected override Task fixtureSetup() CreateTarget("sql", "mssql"), CreateTarget(".net", "json", "mssql", "c#") ]; - return theStore.BulkInsertAsync(_allTargets); + await theStore.BulkInsertAsync(_allTargets); } [Fact] diff --git a/src/LinqTests/Operators/last_operator.cs b/src/LinqTests/Operators/last_operator.cs index 4a20c07874..82f8b0af4c 100644 --- a/src/LinqTests/Operators/last_operator.cs +++ b/src/LinqTests/Operators/last_operator.cs @@ -40,6 +40,11 @@ public async Task last_or_default_throws_an_exception() } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public last_operator(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/modulo_operator.cs b/src/LinqTests/Operators/modulo_operator.cs index 97eda1105a..9ff2b88866 100644 --- a/src/LinqTests/Operators/modulo_operator.cs +++ b/src/LinqTests/Operators/modulo_operator.cs @@ -43,6 +43,11 @@ public async Task use_modulo_operands_reversed() .ShouldHaveTheSameElementsAs(2, 4); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public query_with_modulo_Tests(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/negation_operator.cs b/src/LinqTests/Operators/negation_operator.cs index 374ae47637..1970e831da 100644 --- a/src/LinqTests/Operators/negation_operator.cs +++ b/src/LinqTests/Operators/negation_operator.cs @@ -48,6 +48,11 @@ public async Task negating_predicate_with_an_or_operator_results_in_a_correct_qu players.Count(x => new[] { player2.Id, player4.Id }.Contains(x.Id)).ShouldBe(2); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public negation_operator(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/single_operator.cs b/src/LinqTests/Operators/single_operator.cs index 87b0225928..32b798bd13 100644 --- a/src/LinqTests/Operators/single_operator.cs +++ b/src/LinqTests/Operators/single_operator.cs @@ -5,14 +5,10 @@ using Marten.Testing.Documents; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; - namespace LinqTests.Operators; public class single_operator : IntegrationContext { - private readonly ITestOutputHelper _output; - #region sample_single_and_single_or_default [Fact] public async Task single_hit_with_only_one_document() @@ -69,8 +65,6 @@ public async Task single_hit_with_more_than_one_match() [Fact] public async Task single_hit_with_more_than_one_match_and_take_one_should_not_throw() { - theSession.Logger = new TestOutputMartenLogger(_output); - theSession.Store(new Target { Number = 1 }); theSession.Store(new Target { Number = 2 }); theSession.Store(new Target { Number = 2 }); @@ -207,8 +201,12 @@ await Should.ThrowAsync(async () => }); } - public single_operator(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + + public single_operator(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } } diff --git a/src/LinqTests/Operators/string_compare_operator.cs b/src/LinqTests/Operators/string_compare_operator.cs index 8a698cdead..710a19781b 100644 --- a/src/LinqTests/Operators/string_compare_operator.cs +++ b/src/LinqTests/Operators/string_compare_operator.cs @@ -36,6 +36,11 @@ public async Task string_compare_to_works() queryable.ToList().Count.ShouldBe(2); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public string_compare_operator(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/Operators/to_list_operator.cs b/src/LinqTests/Operators/to_list_operator.cs index a45abad589..275153572d 100644 --- a/src/LinqTests/Operators/to_list_operator.cs +++ b/src/LinqTests/Operators/to_list_operator.cs @@ -39,6 +39,11 @@ public async Task should_return_empty_list() users.ShouldBeEmpty(); } + protected override async Task fixtureSetup() + { + await theStore.Advanced.ResetAllData(); + } + public to_list_operator(DefaultStoreFixture fixture) : base(fixture) { } diff --git a/src/LinqTests/playing.cs b/src/LinqTests/playing.cs index 07c2f4bcad..ece1180a4b 100644 --- a/src/LinqTests/playing.cs +++ b/src/LinqTests/playing.cs @@ -4,23 +4,18 @@ using Marten; using Marten.Testing.Documents; using Marten.Testing.Harness; -using Xunit.Abstractions; - namespace LinqTests; public class playing : IntegrationContext { - private readonly ITestOutputHelper _output; - - public playing(DefaultStoreFixture fixture, ITestOutputHelper output) : base(fixture) + public playing(DefaultStoreFixture fixture) : base(fixture) { - _output = output; } [Fact] public async Task try_method_parsing() { - theSession.Logger = new TestOutputMartenLogger(_output); + await theStore.Advanced.ResetAllData(); var data = await theSession.Query().Where(x => x.String.ToLower().IsOneOf("red", "blue")).ToListAsync(); } } diff --git a/src/Marten.Testing/Harness/IntegrationContext.cs b/src/Marten.Testing/Harness/IntegrationContext.cs index 1442ed225c..cfaff2362f 100644 --- a/src/Marten.Testing/Harness/IntegrationContext.cs +++ b/src/Marten.Testing/Harness/IntegrationContext.cs @@ -180,9 +180,6 @@ public virtual void Dispose() public async Task InitializeAsync() { - await _fixture.Store.Advanced.Clean.DeleteAllDocumentsAsync(); - await _fixture.Store.Advanced.Clean.DeleteAllEventDataAsync(); - await fixtureSetup(); } diff --git a/src/Marten.Testing/Harness/OneOffConfigurationsContext.cs b/src/Marten.Testing/Harness/OneOffConfigurationsContext.cs index 5cf35a594e..6ee5d90cf6 100644 --- a/src/Marten.Testing/Harness/OneOffConfigurationsContext.cs +++ b/src/Marten.Testing/Harness/OneOffConfigurationsContext.cs @@ -57,6 +57,19 @@ protected DocumentStore SeparateStore(Action configure = null) } protected DocumentStore StoreOptions(Action configure, bool cleanAll = true) + { + try + { + return storeOptions(configure, cleanAll); + } + catch (PostgresException e) when (e.SqlState == PostgresErrorCodes.DeadlockDetected) + { + System.Threading.Thread.Sleep(250); + return storeOptions(configure, cleanAll); + } + } + + private DocumentStore storeOptions(Action configure, bool cleanAll) { var options = new StoreOptions(); options.Connection(ConnectionSource.ConnectionString); diff --git a/src/MultiTenancyTests/marten_managed_tenant_id_partitioning.cs b/src/MultiTenancyTests/marten_managed_tenant_id_partitioning.cs index 86935fcb4f..bb04d60522 100644 --- a/src/MultiTenancyTests/marten_managed_tenant_id_partitioning.cs +++ b/src/MultiTenancyTests/marten_managed_tenant_id_partitioning.cs @@ -13,53 +13,76 @@ using Marten.Testing.Harness; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.FSharp.Control; using Npgsql; using Shouldly; using Weasel.Postgresql; using Weasel.Postgresql.Tables; using Weasel.Postgresql.Tables.Partitioning; +using Xunit; namespace MultiTenancyTests; -public class marten_managed_tenant_id_partitioning: OneOffConfigurationsContext, IAsyncLifetime +public class MartenManagedPartitioningFixture: StoreFixture, IAsyncLifetime { + public const string Schema = "marten_managed_partitioning"; + + public MartenManagedPartitioningFixture(): base(Schema) + { + Options.Policies.AllDocumentsAreMultiTenanted(); + Options.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); + Options.Events.TenancyStyle = TenancyStyle.Conjoined; + + Options.Schema.For(); + Options.Schema.For(); + + #region sample_exempt_from_partitioning_through_fluent_interface + + Options.Schema.For().DoNotPartition(); + + #endregion + + Options.Projections.LiveStreamAggregation(); + } + public async Task InitializeAsync() { - using var conn = new NpgsqlConnection(ConnectionSource.ConnectionString); + await using var conn = new NpgsqlConnection(ConnectionSource.ConnectionString); await conn.OpenAsync(); - try - { - await conn.DropSchemaAsync("tenants"); + try { await conn.DropSchemaAsync("tenants"); } catch (Exception) { } + try { await conn.DropSchemaAsync(Schema); } catch (Exception) { } + } - // await conn.CreateCommand($"delete from tenants.{MartenManagedTenantListPartitions.TableName}") - // .ExecuteNonQueryAsync(); - } - catch (Exception) - { - // being lazy here - } + public Task DisposeAsync() => Task.CompletedTask; +} + +[CollectionDefinition("marten_managed_partitioning")] +public class MartenManagedPartitioningCollection: ICollectionFixture +{ +} - await conn.CloseAsync(); +[Collection("marten_managed_partitioning")] +public class marten_managed_tenant_id_partitioning: StoreContext, IAsyncLifetime +{ + public marten_managed_tenant_id_partitioning(MartenManagedPartitioningFixture fixture): base(fixture) + { } - public Task DisposeAsync() + public async Task InitializeAsync() { - return Task.CompletedTask; + await using var conn = new NpgsqlConnection(ConnectionSource.ConnectionString); + await conn.OpenAsync(); + try { await conn.DropSchemaAsync("tenants"); } catch (Exception) { } + try { await conn.DropSchemaAsync(MartenManagedPartitioningFixture.Schema); } catch (Exception) { } + + // Reset the store's cached schema state so it will recreate tables after the schema drop + ((MartenDatabase)theStore.Storage.Database).ResetSchemaExistenceChecks(); } + public Task DisposeAsync() => Task.CompletedTask; + [Fact] public async Task can_build_storage_with_dynamic_tenants() { - StoreOptions(opts => - { - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Schema.For(); - opts.Schema.For(); - }, true); - #region sample_add_managed_tenants_at_runtime await theStore @@ -83,15 +106,6 @@ await theStore [Fact] public async Task add_then_remove_tenants_at_runtime() { - StoreOptions(opts => - { - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Schema.For(); - opts.Schema.For(); - }, true); - await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); var statuses = await theStore @@ -120,17 +134,6 @@ public async Task add_then_remove_tenants_at_runtime() [Fact] public async Task delete_all_tenant_data_will_drop_partitions() { - StoreOptions(opts => - { - opts.Events.TenancyStyle = TenancyStyle.Conjoined; - - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Schema.For(); - opts.Schema.For(); - }, true); - await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); await theStore.Storage.Database.EnsureStorageExistsAsync(typeof(IEvent)); @@ -162,19 +165,6 @@ public async Task delete_all_tenant_data_will_drop_partitions() [Fact] public async Task should_not_build_storage_for_live_aggregations() { - StoreOptions(opts => - { - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Events.TenancyStyle = TenancyStyle.Conjoined; - - opts.Schema.For(); - opts.Schema.For(); - - opts.Projections.LiveStreamAggregation(); - }, true); - var streamId = theSession.Events.StartStream(new RandomEvent(), new BEvent()).Id; await theSession.SaveChangesAsync(); @@ -197,15 +187,6 @@ await theStore [Fact] public async Task can_build_storage_with_dynamic_tenants_by_variable_tenant_and_suffix_mappings() { - StoreOptions(opts => - { - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Schema.For(); - opts.Schema.For(); - }, true); - var tenantId1 = Guid.NewGuid().ToString(); var tenantId2 = Guid.NewGuid().ToString(); var tenantId3 = Guid.NewGuid().ToString(); @@ -234,15 +215,6 @@ await theStore [Fact] public async Task can_build_then_add_additive_partitions_later() { - StoreOptions(opts => - { - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Schema.For(); - opts.Schema.For(); - }, true); - await theStore.Advanced.AddMartenManagedTenantsAsync(CancellationToken.None, "a1", "a2", "a3"); await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); @@ -303,15 +275,6 @@ public static async Task sample_configuration() [Fact] public void exempt_from_partitioning_through_attribute_usage() { - StoreOptions(opts => - { - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Schema.For(); - opts.Schema.For(); - }, true); - var mapping = theStore.Options.Storage.MappingFor(typeof(DocThatShouldBeExempted1)); mapping.DisablePartitioningIfAny.ShouldBeTrue(); @@ -322,21 +285,6 @@ public void exempt_from_partitioning_through_attribute_usage() [Fact] public void exempt_from_partitioning_through_fluent_interface_usage() { - StoreOptions(opts => - { - opts.Policies.AllDocumentsAreMultiTenanted(); - opts.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("tenants"); - - opts.Schema.For(); - opts.Schema.For(); - - #region sample_exempt_from_partitioning_through_fluent_interface - - opts.Schema.For().DoNotPartition(); - - #endregion - }, true); - var mapping = theStore.Options.Storage.MappingFor(typeof(DocThatShouldBeExempted2)); mapping.DisablePartitioningIfAny.ShouldBeTrue(); @@ -403,5 +351,3 @@ public class BEvent{} public class CEvent{} public class DEvent{} public class EEvent{} - - diff --git a/src/MultiTenancyTests/using_database_per_tenant.cs b/src/MultiTenancyTests/using_database_per_tenant.cs index 3ea2ca2238..e8fcf9e19e 100644 --- a/src/MultiTenancyTests/using_database_per_tenant.cs +++ b/src/MultiTenancyTests/using_database_per_tenant.cs @@ -4,19 +4,13 @@ using Marten.Exceptions; using Marten.Testing.Harness; using Shouldly; -using Xunit.Abstractions; namespace MultiTenancyTests; public class using_database_per_tenant: IAsyncLifetime { - private readonly ITestOutputHelper _testOutputHelper; private DocumentStore _theStore; - public using_database_per_tenant( - ITestOutputHelper testOutputHelper - ) => _testOutputHelper = testOutputHelper; - public async Task InitializeAsync() { _theStore = DocumentStore.For( diff --git a/src/PatchingTests/Patching/Bug_2170_patch_with_sub_collection_query.cs b/src/PatchingTests/Patching/Bug_2170_patch_with_sub_collection_query.cs index 50e243f510..0d4f33535b 100644 --- a/src/PatchingTests/Patching/Bug_2170_patch_with_sub_collection_query.cs +++ b/src/PatchingTests/Patching/Bug_2170_patch_with_sub_collection_query.cs @@ -5,25 +5,16 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace PatchingTests.Patching; public class Bug_2170_patch_with_sub_collection_query : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_2170_patch_with_sub_collection_query(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task work_correctly() { StoreOptions(opts => { - opts.Logger(new TestOutputMartenLogger(_output)); }); await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); diff --git a/src/PatchingTests/Patching/Bug_3261_patch_plus_revisions.cs b/src/PatchingTests/Patching/Bug_3261_patch_plus_revisions.cs index 0d3a6ba17f..0ed8a4e2fd 100644 --- a/src/PatchingTests/Patching/Bug_3261_patch_plus_revisions.cs +++ b/src/PatchingTests/Patching/Bug_3261_patch_plus_revisions.cs @@ -3,19 +3,11 @@ using Marten.Patching; using Marten.Testing.Harness; using Xunit; -using Xunit.Abstractions; namespace PatchingTests.Patching; public class Bug_3261_patch_plus_revisions : BugIntegrationContext { - private readonly ITestOutputHelper _output; - - public Bug_3261_patch_plus_revisions(ITestOutputHelper output) - { - _output = output; - } - [Fact] public async Task can_use_patch_with_revision() { @@ -28,8 +20,6 @@ public async Task can_use_patch_with_revision() theSession.Store(doc); await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - theSession.Patch(d => d.Id == doc.Id && d.AnyTenant()).Set("name", "newvalue"); await theSession.SaveChangesAsync(); diff --git a/src/PatchingTests/Patching/multi_tenancy.cs b/src/PatchingTests/Patching/multi_tenancy.cs index c35c2fc418..faf602ff72 100644 --- a/src/PatchingTests/Patching/multi_tenancy.cs +++ b/src/PatchingTests/Patching/multi_tenancy.cs @@ -7,7 +7,6 @@ using Marten.Testing.Harness; using Shouldly; using Xunit; -using Xunit.Abstractions; namespace PatchingTests.Patching; @@ -23,7 +22,6 @@ public MultiTenancyFixture(): base("multi_tenancy") [Collection("multi_tenancy")] public class multi_tenancy: StoreContext, IClassFixture, IAsyncLifetime { - private readonly ITestOutputHelper _output; private readonly Target[] _greens = Target.GenerateRandomData(100).ToArray(); private readonly Target[] _reds = Target.GenerateRandomData(100).ToArray(); @@ -33,10 +31,8 @@ public class multi_tenancy: StoreContext, IClassFixture(target1.Id).Set(x => x.Number, 2); await theSession.SaveChangesAsync(); diff --git a/src/ValueTypeTests/include_usage.cs b/src/ValueTypeTests/include_usage.cs index 5285f1e461..f20336266e 100644 --- a/src/ValueTypeTests/include_usage.cs +++ b/src/ValueTypeTests/include_usage.cs @@ -8,20 +8,16 @@ using Marten.Testing.Harness; using Shouldly; using Vogen; -using Xunit.Abstractions; namespace ValueTypeTests; public class include_usage : IAsyncDisposable { - private readonly ITestOutputHelper _output; private readonly DocumentStore theStore; private IDocumentSession theSession; - public include_usage(ITestOutputHelper output) + public include_usage() { - _output = output; - theStore = DocumentStore.For(opts => { opts.Connection(ConnectionSource.ConnectionString); @@ -59,8 +55,6 @@ public async Task include_a_single_reference() await theSession.SaveChangesAsync(); - theSession.Logger = new TestOutputMartenLogger(_output); - var list = new List(); var loaded = await theSession