diff --git a/src/ValueTypeTests/StrongTypedId/check_exists_with_strong_typed_ids.cs b/src/ValueTypeTests/StrongTypedId/check_exists_with_strong_typed_ids.cs index 4dbb5431e1..d1e3ab82d3 100644 --- a/src/ValueTypeTests/StrongTypedId/check_exists_with_strong_typed_ids.cs +++ b/src/ValueTypeTests/StrongTypedId/check_exists_with_strong_typed_ids.cs @@ -7,36 +7,8 @@ namespace ValueTypeTests.StrongTypedId; -public class check_exists_with_strong_typed_ids: IDisposable, IAsyncDisposable +public class check_exists_with_strong_typed_ids: OneOffConfigurationsContext { - private readonly DocumentStore theStore; - private IDocumentSession theSession; - - public check_exists_with_strong_typed_ids() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed_exists"; - }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } - [Fact] public async Task check_exists_with_guid_strong_typed_id_hit() { diff --git a/src/ValueTypeTests/StrongTypedId/duplicated_value_type_field_operations.cs b/src/ValueTypeTests/StrongTypedId/duplicated_value_type_field_operations.cs index 14fb908593..427c1274f6 100644 --- a/src/ValueTypeTests/StrongTypedId/duplicated_value_type_field_operations.cs +++ b/src/ValueTypeTests/StrongTypedId/duplicated_value_type_field_operations.cs @@ -9,37 +9,15 @@ namespace ValueTypeTests.StrongTypedId; -public class duplicated_value_type_field_operations : IDisposable, IAsyncDisposable +public class duplicated_value_type_field_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - private IDocumentSession theSession; - public duplicated_value_type_field_operations() { - theStore = DocumentStore.For(opts => + StoreOptions(opts => { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "duplicated_value_type_field1"; - opts.RegisterValueType(); opts.Schema.For().Duplicate(x => x.DuplicateValueType); }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } } [Fact] diff --git a/src/ValueTypeTests/StrongTypedId/fsharp_discriminated_union_document_operations.cs b/src/ValueTypeTests/StrongTypedId/fsharp_discriminated_union_document_operations.cs index 3d248c2335..32d43b5e68 100644 --- a/src/ValueTypeTests/StrongTypedId/fsharp_discriminated_union_document_operations.cs +++ b/src/ValueTypeTests/StrongTypedId/fsharp_discriminated_union_document_operations.cs @@ -15,21 +15,10 @@ namespace ValueTypeTests.StrongTypedId; -public class fsharp_discriminated_union_document_operations: IDisposable, IAsyncDisposable +public class fsharp_discriminated_union_document_operations: OneOffConfigurationsContext { - private readonly DocumentStore theStore; - private readonly IDocumentSession theSession; - public fsharp_discriminated_union_document_operations() { - var schemaName = "strong_typed_fsharp"; - var options = new StoreOptions(); - options.Connection(ConnectionSource.ConnectionString); - - options.AutoCreateSchemaObjects = AutoCreate.All; - options.NameDataLength = 100; - options.DatabaseSchemaName = schemaName; - //For docs on these options see: https://github.com/Tarmil/FSharp.SystemTextJson/blob/master/docs/Customizing.md var jsonFSharpOptions = JsonFSharpOptions @@ -39,34 +28,13 @@ public fsharp_discriminated_union_document_operations() .WithUnionUnwrapSingleCaseUnions() .WithSkippableOptionFields(); - options.UseSystemTextJsonForSerialization(configure: (jsonOptions) => + StoreOptions(options => { - jsonFSharpOptions.AddToJsonSerializerOptions(jsonOptions); + options.UseSystemTextJsonForSerialization(configure: (jsonOptions) => + { + jsonFSharpOptions.AddToJsonSerializerOptions(jsonOptions); + }); }); - - // clean-up - using var conn = new NpgsqlConnection(ConnectionSource.ConnectionString); - conn.Open(); - conn.CreateCommand($"drop schema if exists {schemaName} cascade") - .ExecuteNonQuery(); - - - theStore = new DocumentStore(options); - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } } [Fact] diff --git a/src/ValueTypeTests/StrongTypedId/guid_based_document_operations.cs b/src/ValueTypeTests/StrongTypedId/guid_based_document_operations.cs index 01cf392f1e..30a878dbb1 100644 --- a/src/ValueTypeTests/StrongTypedId/guid_based_document_operations.cs +++ b/src/ValueTypeTests/StrongTypedId/guid_based_document_operations.cs @@ -11,36 +11,8 @@ namespace ValueTypeTests.StrongTypedId; -public class guid_id_document_operations : IDisposable, IAsyncDisposable +public class guid_id_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public guid_id_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed1"; - }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } [Fact] public void store_document_will_assign_the_identity() @@ -293,36 +265,8 @@ public class Invoice3 public string Name { get; set; } } -public class guid_id_document_operations_with_non_nullable_identifier : IDisposable, IAsyncDisposable +public class guid_id_document_operations_with_non_nullable_identifier : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public guid_id_document_operations_with_non_nullable_identifier() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed21"; - }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } [Fact] public void store_document_will_assign_the_identity() diff --git a/src/ValueTypeTests/StrongTypedId/int_based_document_operations.cs b/src/ValueTypeTests/StrongTypedId/int_based_document_operations.cs index e3bea8dbe4..b8af861b09 100644 --- a/src/ValueTypeTests/StrongTypedId/int_based_document_operations.cs +++ b/src/ValueTypeTests/StrongTypedId/int_based_document_operations.cs @@ -10,33 +10,8 @@ namespace ValueTypeTests.StrongTypedId; -public class int_based_document_operations : IAsyncLifetime +public class int_based_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public int_based_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed2"; - }); - - theSession = theStore.LightweightSession(); - } - - public async ValueTask InitializeAsync() - { - await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Order2)); - } - - public async ValueTask DisposeAsync() - { - await theStore.DisposeAsync(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; [Fact] public void store_document_will_assign_the_identity() @@ -278,33 +253,8 @@ public class Order3 public string Name { get; set; } } -public class int_based_document_operations_with_non_nullable_id : IAsyncLifetime +public class int_based_document_operations_with_non_nullable_id : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public int_based_document_operations_with_non_nullable_id() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed20"; - }); - - theSession = theStore.LightweightSession(); - } - - public async ValueTask InitializeAsync() - { - await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Order3)); - } - - public async ValueTask DisposeAsync() - { - await theStore.DisposeAsync(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; [Fact] public void store_document_will_assign_the_identity() diff --git a/src/ValueTypeTests/StrongTypedId/long_based_document_operations.cs b/src/ValueTypeTests/StrongTypedId/long_based_document_operations.cs index b413a4bf31..47de5b3065 100644 --- a/src/ValueTypeTests/StrongTypedId/long_based_document_operations.cs +++ b/src/ValueTypeTests/StrongTypedId/long_based_document_operations.cs @@ -10,33 +10,8 @@ namespace ValueTypeTests.StrongTypedId; -public class long_based_document_operations : IAsyncLifetime +public class long_based_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public long_based_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed3"; - }); - - theSession = theStore.LightweightSession(); - } - - public async ValueTask InitializeAsync() - { - await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Issue2)); - } - - public async ValueTask DisposeAsync() - { - await theStore.DisposeAsync(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; [Fact] public void store_document_will_assign_the_identity() @@ -281,33 +256,8 @@ public class Issue3 public string Name { get; set; } } -public class long_based_document_operations_with_non_nullable_id : IAsyncLifetime +public class long_based_document_operations_with_non_nullable_id : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public long_based_document_operations_with_non_nullable_id() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed22"; - }); - - theSession = theStore.LightweightSession(); - } - - public async ValueTask InitializeAsync() - { - await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Issue3)); - } - - public async ValueTask DisposeAsync() - { - await theStore.DisposeAsync(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; [Fact] public void store_document_will_assign_the_identity() diff --git a/src/ValueTypeTests/StrongTypedId/string_id_document_operations.cs b/src/ValueTypeTests/StrongTypedId/string_id_document_operations.cs index 6af98b4a5f..6344628d55 100644 --- a/src/ValueTypeTests/StrongTypedId/string_id_document_operations.cs +++ b/src/ValueTypeTests/StrongTypedId/string_id_document_operations.cs @@ -11,36 +11,8 @@ namespace ValueTypeTests.StrongTypedId; -public class string_id_document_operations : IDisposable, IAsyncDisposable +public class string_id_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public string_id_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed4"; - }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } [Fact] public async Task store_a_document_smoke_test() @@ -253,36 +225,8 @@ public class Team3 public string Name { get; set; } } -public class string_id_document_operations_with_non_nullable_id : IDisposable, IAsyncDisposable +public class string_id_document_operations_with_non_nullable_id : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public string_id_document_operations_with_non_nullable_id() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed23"; - }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } [Fact] public async Task store_a_document_smoke_test() diff --git a/src/ValueTypeTests/VogenIds/duplicated_value_type_field_operations.cs b/src/ValueTypeTests/VogenIds/duplicated_value_type_field_operations.cs index 96e02a7270..fadf2c1a7c 100644 --- a/src/ValueTypeTests/VogenIds/duplicated_value_type_field_operations.cs +++ b/src/ValueTypeTests/VogenIds/duplicated_value_type_field_operations.cs @@ -9,37 +9,15 @@ namespace ValueTypeTests.VogenIds; -public class duplicated_value_type_field_operations : IDisposable, IAsyncDisposable +public class duplicated_value_type_field_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - private IDocumentSession theSession; - public duplicated_value_type_field_operations() { - theStore = DocumentStore.For(opts => + StoreOptions(opts => { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "duplicated_value_type_field2"; - opts.RegisterValueType(); opts.Schema.For().Duplicate(x => x.DuplicateValueType); }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } } [Fact] diff --git a/src/ValueTypeTests/VogenIds/guid_based_document_operations.cs b/src/ValueTypeTests/VogenIds/guid_based_document_operations.cs index b22ae27635..6434d2ed25 100644 --- a/src/ValueTypeTests/VogenIds/guid_based_document_operations.cs +++ b/src/ValueTypeTests/VogenIds/guid_based_document_operations.cs @@ -11,36 +11,8 @@ namespace ValueTypeTests.VogenIds; -public class guid_id_document_operations : IDisposable, IAsyncDisposable +public class guid_id_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public guid_id_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed5"; - }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } [Fact] public void store_document_will_assign_the_identity() diff --git a/src/ValueTypeTests/VogenIds/int_based_document_operations.cs b/src/ValueTypeTests/VogenIds/int_based_document_operations.cs index 19699cdc11..fe8695b94d 100644 --- a/src/ValueTypeTests/VogenIds/int_based_document_operations.cs +++ b/src/ValueTypeTests/VogenIds/int_based_document_operations.cs @@ -9,33 +9,8 @@ namespace ValueTypeTests.VogenIds; -public class int_based_document_operations : IAsyncLifetime +public class int_based_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public int_based_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed6"; - }); - - theSession = theStore.LightweightSession(); - } - - public async ValueTask InitializeAsync() - { - await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Order)); - } - - public async ValueTask DisposeAsync() - { - await theStore.DisposeAsync(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; [Fact] public void store_document_will_assign_the_identity() diff --git a/src/ValueTypeTests/VogenIds/long_based_document_operations.cs b/src/ValueTypeTests/VogenIds/long_based_document_operations.cs index 253c522e1c..eb21e22009 100644 --- a/src/ValueTypeTests/VogenIds/long_based_document_operations.cs +++ b/src/ValueTypeTests/VogenIds/long_based_document_operations.cs @@ -9,33 +9,8 @@ namespace ValueTypeTests.VogenIds; -public class long_based_document_operations : IAsyncLifetime +public class long_based_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public long_based_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed7"; - }); - - theSession = theStore.LightweightSession(); - } - - public async ValueTask InitializeAsync() - { - await theStore.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Issue)); - } - - public async ValueTask DisposeAsync() - { - await theStore.DisposeAsync(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; [Fact] public void store_document_will_assign_the_identity() diff --git a/src/ValueTypeTests/VogenIds/string_id_document_operations.cs b/src/ValueTypeTests/VogenIds/string_id_document_operations.cs index 20f96657ec..fe64bd4650 100644 --- a/src/ValueTypeTests/VogenIds/string_id_document_operations.cs +++ b/src/ValueTypeTests/VogenIds/string_id_document_operations.cs @@ -10,36 +10,8 @@ namespace ValueTypeTests.VogenIds; -public class string_id_document_operations : IDisposable, IAsyncDisposable +public class string_id_document_operations : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - - public string_id_document_operations() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed8"; - }); - - theSession = theStore.LightweightSession(); - } - - public void Dispose() - { - theStore?.Dispose(); - theSession?.Dispose(); - } - - private IDocumentSession theSession; - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } [Fact] public async Task store_a_document_smoke_test() diff --git a/src/ValueTypeTests/include_usage.cs b/src/ValueTypeTests/include_usage.cs index 35436cdc8a..4117667d6c 100644 --- a/src/ValueTypeTests/include_usage.cs +++ b/src/ValueTypeTests/include_usage.cs @@ -10,30 +10,8 @@ namespace ValueTypeTests; -public class include_usage : IAsyncDisposable +public class include_usage : OneOffConfigurationsContext { - private readonly DocumentStore theStore; - private IDocumentSession theSession; - - public include_usage() - { - theStore = DocumentStore.For(opts => - { - opts.Connection(ConnectionSource.ConnectionString); - opts.DatabaseSchemaName = "strong_typed24"; - }); - - theSession = theStore.LightweightSession(); - } - - public async ValueTask DisposeAsync() - { - if (theStore != null) - { - await theStore.DisposeAsync(); - } - } - #region sample_include_a_single_reference_with_strong_identifier [Fact]