Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DuplicateValueType>();
opts.Schema.For<DuplicateValueTypeDoc>().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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
60 changes: 2 additions & 58 deletions src/ValueTypeTests/StrongTypedId/guid_based_document_operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
54 changes: 2 additions & 52 deletions src/ValueTypeTests/StrongTypedId/int_based_document_operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
54 changes: 2 additions & 52 deletions src/ValueTypeTests/StrongTypedId/long_based_document_operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
Loading
Loading