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
18 changes: 9 additions & 9 deletions Xfty.AutoBogus.Test/AutoBogusUnsetFieldFillerTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using global::AutoBogus;
using Net.NowhereAtAll.Xfty.AutoBogus;
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Demo;
using Net.NowhereAtAll.Xfty.Lookup;

Expand All @@ -12,8 +12,8 @@ public class AutoBogusUnsetFieldFillerTest
private static IProviderLookup Lookup() =>
ProviderLookups.Of(new Dictionary<ILookupKey, IRecordProvider>
{
[LookupKey.Get(typeof(Account))] = new AccountDataProvider(),
[LookupKey.Get(typeof(Contact))] = new ContactDataProvider(),
[LookupKey.Get<Account>()] = new AccountDataProvider(),
[LookupKey.Get<Contact>()] = new ContactDataProvider(),
});

[Fact]
Expand All @@ -26,7 +26,7 @@ public async Task Supply_FillsFieldsTheMasterTemplateNeverConfigured_WithRealAut
.SetUnsetFieldFiller(new AutoBogusUnsetFieldFiller(faker));

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert - AccountDataProvider's own Master Template never touches these
_ = Assert.NotNull(result.NumberOfEmployees);
Expand All @@ -44,7 +44,7 @@ public async Task Supply_NeverOverwritesAFieldTheMasterTemplateDidConfigure()
.SetUnsetFieldFiller(new AutoBogusUnsetFieldFiller(faker));

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert - AccountDataProvider's own declared defaults, untouched by AutoBogus
Assert.StartsWith(AccountDataProvider.DefaultNamePrefix, result.Name);
Expand All @@ -63,7 +63,7 @@ public async Task Excluding_LeavesThatOneFieldExactlyAsXftyLeftIt()
.SetUnsetFieldFiller(filler);

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert - excluded field stays null; a sibling unset field still gets filled
Assert.Null(result.Site);
Expand All @@ -84,7 +84,7 @@ public async Task Excluding_ChainedForEveryNavigationProperty_LeavesAllOfThemUnt
.SetUnsetFieldFiller(filler);

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert
Assert.Null(result.Contacts);
Expand All @@ -103,7 +103,7 @@ public async Task Supply_ForASelfReferencingUnsetField_NeverThrows()
.SetUnsetFieldFiller(new AutoBogusUnsetFieldFiller(faker));

// Act
Exception? thrown = await Record.ExceptionAsync(provider.Supply);
Exception? thrown = await Record.ExceptionAsync(provider.Supply).ConfigureAwait(true);

// Assert
Assert.Null(thrown);
Expand All @@ -121,7 +121,7 @@ public async Task Supply_CombinedWithXftyAutoBogus_FillsAScalarFieldWhileStillGe
.SetUnsetFieldFiller(new AutoBogusUnsetFieldFiller(faker));

// Act
Contact result = (Contact)await provider.Supply();
Contact result = (Contact)await provider.Supply().ConfigureAwait(true);

// Assert
Assert.NotNull(result.AccountId); // XFTY's own relationship resolution
Expand Down
6 changes: 3 additions & 3 deletions Xfty.AutoBogus.Test/XftyAutoBogusTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using global::AutoBogus;
using Net.NowhereAtAll.Xfty.AutoBogus;
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Demo;
using Net.NowhereAtAll.Xfty.Lookup;

Expand All @@ -15,8 +15,8 @@ public class XftyAutoBogusTest
private static IProviderLookup Lookup() =>
ProviderLookups.Of(new Dictionary<ILookupKey, IRecordProvider>
{
[LookupKey.Get(typeof(Account))] = new AccountDataProvider(),
[LookupKey.Get(typeof(Contact))] = new ContactDataProvider(),
[LookupKey.Get<Account>()] = new AccountDataProvider(),
[LookupKey.Get<Contact>()] = new ContactDataProvider(),
});

[Fact]
Expand Down
1 change: 1 addition & 0 deletions Xfty.AutoBogus/XftyAutoBogusOverride.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using global::AutoBogus;
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Lookup;

namespace Net.NowhereAtAll.Xfty.AutoBogus;
Expand Down
23 changes: 11 additions & 12 deletions Xfty.AutoFixture.Test/AutoFixtureUnsetFieldFillerTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using global::AutoFixture;
using global::AutoFixture.Kernel;
using Net.NowhereAtAll.Xfty.AutoFixture;
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Demo;
using Net.NowhereAtAll.Xfty.Lookup;

Expand All @@ -13,8 +12,8 @@ public class AutoFixtureUnsetFieldFillerTest
private static IProviderLookup Lookup() =>
ProviderLookups.Of(new Dictionary<ILookupKey, IRecordProvider>
{
[LookupKey.Get(typeof(Account))] = new AccountDataProvider(),
[LookupKey.Get(typeof(Contact))] = new ContactDataProvider(),
[LookupKey.Get<Account>()] = new AccountDataProvider(),
[LookupKey.Get<Contact>()] = new ContactDataProvider(),
});

[Fact]
Expand All @@ -27,7 +26,7 @@ public async Task Supply_FillsFieldsTheMasterTemplateNeverConfigured_WithRealAut
.SetUnsetFieldFiller(new AutoFixtureUnsetFieldFiller(fixture));

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert - AccountDataProvider's own Master Template never touches these
_ = Assert.NotNull(result.NumberOfEmployees);
Expand All @@ -45,7 +44,7 @@ public async Task Supply_NeverOverwritesAFieldTheMasterTemplateDidConfigure()
.SetUnsetFieldFiller(new AutoFixtureUnsetFieldFiller(fixture));

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert - AccountDataProvider's own declared defaults, untouched by AutoFixture
Assert.StartsWith(AccountDataProvider.DefaultNamePrefix, result.Name);
Expand All @@ -64,7 +63,7 @@ public async Task Excluding_LeavesThatOneFieldExactlyAsXftyLeftIt()
.SetUnsetFieldFiller(filler);

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert - excluded field stays null; a sibling unset field still gets filled
Assert.Null(result.Site);
Expand All @@ -85,7 +84,7 @@ public async Task Excluding_ChainedForEveryNavigationProperty_LeavesAllOfThemUnt
.SetUnsetFieldFiller(filler);

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert
Assert.Null(result.Contacts);
Expand All @@ -98,14 +97,14 @@ public async Task Supply_WithOmitOnRecursionBehaviorInstalled_StillFillsTheSelfR
{
// Arrange - the documented alternative to relying on this filler's own catch
IFixture fixture = new Fixture();
_ = fixture.Behaviors.Remove(fixture.Behaviors.OfType<ThrowingRecursionBehavior>().Single());
_ = fixture.Behaviors.Remove(fixture.Behaviors.OfType<ThrowingRecursionBehavior>().First());
fixture.Behaviors.Add(new OmitOnRecursionBehavior());
RecordProvider provider = new RecordProvider(typeof(Account), Lookup())
.SetInsertMode(InsertMode.Mock)
.SetUnsetFieldFiller(new AutoFixtureUnsetFieldFiller(fixture));

// Act
Exception? thrown = await Record.ExceptionAsync(provider.Supply);
Exception? thrown = await Record.ExceptionAsync(provider.Supply).ConfigureAwait(true);

// Assert
Assert.Null(thrown);
Expand All @@ -122,7 +121,7 @@ public async Task Supply_ForASelfReferencingUnsetField_NeverLetsAFixturesRecursi
.SetUnsetFieldFiller(new AutoFixtureUnsetFieldFiller(fixture));

// Act
Exception? thrown = await Record.ExceptionAsync(provider.Supply);
Exception? thrown = await Record.ExceptionAsync(provider.Supply).ConfigureAwait(true);

// Assert
Assert.Null(thrown);
Expand All @@ -140,7 +139,7 @@ public async Task Supply_CombinedWithXftyCustomization_FillsAScalarFieldWhileSti
.SetUnsetFieldFiller(new AutoFixtureUnsetFieldFiller(fixture));

// Act
Contact result = (Contact)await provider.Supply();
Contact result = (Contact)await provider.Supply().ConfigureAwait(true);

// Assert
Assert.NotNull(result.AccountId); // XFTY's own relationship resolution
Expand Down
6 changes: 3 additions & 3 deletions Xfty.AutoFixture.Test/XftyCustomizationTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using global::AutoFixture;
using Net.NowhereAtAll.Xfty.AutoFixture;
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Demo;
using Net.NowhereAtAll.Xfty.Lookup;

Expand All @@ -15,8 +15,8 @@ public class XftyCustomizationTest
private static IProviderLookup Lookup() =>
ProviderLookups.Of(new Dictionary<ILookupKey, IRecordProvider>
{
[LookupKey.Get(typeof(Account))] = new AccountDataProvider(),
[LookupKey.Get(typeof(Contact))] = new ContactDataProvider(),
[LookupKey.Get<Account>()] = new AccountDataProvider(),
[LookupKey.Get<Contact>()] = new ContactDataProvider(),
});

private static IFixture Fixture() => new Fixture().Customize(new XftyCustomization(Lookup()));
Expand Down
1 change: 1 addition & 0 deletions Xfty.AutoFixture/XftySpecimenBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using global::AutoFixture.Kernel;
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Lookup;

namespace Net.NowhereAtAll.Xfty.AutoFixture;
Expand Down
6 changes: 4 additions & 2 deletions Xfty.Bogus.Test/BogusReadmeExampleTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.MasterTemplates;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Demo;
using Net.NowhereAtAll.Xfty.Lookup;

Expand All @@ -24,7 +26,7 @@ public class BogusReadmeExampleTest
private static IProviderLookup Lookup() =>
ProviderLookups.Of(new Dictionary<ILookupKey, IRecordProvider>
{
[LookupKey.Get(typeof(Contact))] = new ContactWithFakeDataProvider(),
[LookupKey.Get<Contact>()] = new ContactWithFakeDataProvider(),
});

[Fact]
Expand All @@ -34,7 +36,7 @@ public async Task Supply_UsingBogusExpressionsInAMasterTemplate_ProducesRealisti
IProviderLookup lookup = Lookup();

// Act
Contact result = (Contact)await new RecordProvider(typeof(Contact), lookup).Supply();
Contact result = (Contact)await new RecordProvider(typeof(Contact), lookup).Supply().ConfigureAwait(true);

// Assert
Assert.False(string.IsNullOrWhiteSpace(result.FirstName));
Expand Down
3 changes: 2 additions & 1 deletion Xfty.EntityFrameworkCore.Test/DocumentEmbeddingProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.MasterTemplates;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Values;

namespace Net.NowhereAtAll.Xfty.EntityFrameworkCore.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Net.NowhereAtAll.Xfty.Core;
using Net.NowhereAtAll.Xfty.Core.RecordProviders;
using Net.NowhereAtAll.Xfty.Lookup;

namespace Net.NowhereAtAll.Xfty.EntityFrameworkCore.Test;
Expand All @@ -8,14 +8,14 @@ public sealed class DocumentEmbeddingProviderLookup : IProviderLookup
{
private static readonly Dictionary<ILookupKey, Type> ProviderTypeByKey = new()
{
[LookupKey.Get(typeof(DocumentEmbedding))] = typeof(DocumentEmbeddingProvider),
[LookupKey.Get<DocumentEmbedding>()] = typeof(DocumentEmbeddingProvider),
};

private readonly Dictionary<ILookupKey, IRecordProvider> instanceCache = [];
private readonly Dictionary<ILookupKey, IRecordProvider> InstanceCache = [];

public IRecordProvider Get(Type recordType) => this.Get(LookupKey.Get(recordType));

public IRecordProvider Get(ILookupKey lookupKey) => ProviderLookups.Get(ProviderTypeByKey, this.instanceCache, lookupKey);
public IRecordProvider Get(ILookupKey lookupKey) => ProviderLookups.Get(ProviderTypeByKey, this.InstanceCache, lookupKey);

public ISet<ILookupKey> KeysFor(object? record) => ProviderLookups.KeysFor(ProviderTypeByKey.Keys.ToHashSet(), record);
}
3 changes: 1 addition & 2 deletions Xfty.EntityFrameworkCore.Test/PgVectorPersistenceTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Net.NowhereAtAll.Xfty.Core;
using Pgvector.EntityFrameworkCore;
using Testcontainers.PostgreSql;

namespace Net.NowhereAtAll.Xfty.EntityFrameworkCore.Test;
Expand Down Expand Up @@ -68,7 +67,7 @@ public async Task Supply_InNowMode_AgainstARealPgvectorColumn_ActuallyInsertsThe
.SetPersistenceGateway(new EfPersistenceGateway(this.dbContext!));

// Act
DocumentEmbedding result = (DocumentEmbedding)await provider.Supply();
DocumentEmbedding result = (DocumentEmbedding)await provider.Supply().ConfigureAwait(true);

// Assert
Assert.NotNull(result.Id);
Expand Down
4 changes: 2 additions & 2 deletions Xfty.EntityFrameworkCore.Test/PostgresNowPersistenceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task Supply_InNowMode_AgainstARealPostgresContainer_ActuallyInserts
.SetPersistenceGateway(new EfPersistenceGateway(this.dbContext!));

// Act
Account result = (Account)await provider.Supply();
Account result = (Account)await provider.Supply().ConfigureAwait(true);

// Assert
Assert.NotNull(result.Id);
Expand All @@ -85,7 +85,7 @@ public async Task SupplyBundle_NowPlusDepthBatched_AgainstARealPostgresContainer
.DepthBatched();

// Act
Contact result = (Contact)await provider.Supply();
Contact result = (Contact)await provider.Supply().ConfigureAwait(true);

// Assert
Contact rereadContact = this.dbContext!.Contacts.AsNoTracking().First(c => c.Id == result.Id);
Expand Down
Loading