Skip to content

Commit

Permalink
upgrade autofaker and make all instances static
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Nov 19, 2024
1 parent 3fbf016 commit dde589b
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace FwLiteProjectSync.Tests;

public class EntrySyncTests : IClassFixture<SyncFixture>
{
private readonly AutoFaker _autoFaker = new(builder => builder.WithOverride(new MultiStringOverride()).WithOverride(new ObjectWithIdOverride()));
private static readonly AutoFaker AutoFaker = new(builder => builder.WithOverride(new MultiStringOverride()).WithOverride(new ObjectWithIdOverride()));
public EntrySyncTests(SyncFixture fixture)
{
_fixture = fixture;
Expand All @@ -20,8 +20,8 @@ public EntrySyncTests(SyncFixture fixture)
[Fact]
public async Task CanSyncRandomEntries()
{
var createdEntry = await _fixture.CrdtApi.CreateEntry(await _autoFaker.EntryReadyForCreation(_fixture.CrdtApi));
var after = await _autoFaker.EntryReadyForCreation(_fixture.CrdtApi, entryId: createdEntry.Id);
var createdEntry = await _fixture.CrdtApi.CreateEntry(await AutoFaker.EntryReadyForCreation(_fixture.CrdtApi));
var after = await AutoFaker.EntryReadyForCreation(_fixture.CrdtApi, entryId: createdEntry.Id);
await EntrySync.Sync(after, createdEntry, _fixture.CrdtApi);
var actual = await _fixture.CrdtApi.GetEntry(after.Id);
actual.Should().NotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1"/>
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="2.1.278" />
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="3.0.410" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
8 changes: 4 additions & 4 deletions backend/FwLite/FwLiteProjectSync.Tests/UpdateDiffTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace FwLiteProjectSync.Tests;

public class UpdateDiffTests
{
private readonly AutoFaker _autoFaker = new(new AutoFakerConfig()
private static readonly AutoFaker AutoFaker = new(new AutoFakerConfig()
{
Overrides = [new MultiStringOverride(), new WritingSystemIdOverride()]
});
Expand All @@ -18,7 +18,7 @@ public class UpdateDiffTests
public void EntryDiffShouldUpdateAllFields()
{
var before = new Entry();
var after = _autoFaker.Generate<Entry>();
var after = AutoFaker.Generate<Entry>();
var entryDiffToUpdate = EntrySync.EntryDiffToUpdate(before, after);
ArgumentNullException.ThrowIfNull(entryDiffToUpdate);
entryDiffToUpdate.Apply(before);
Expand All @@ -33,7 +33,7 @@ public void EntryDiffShouldUpdateAllFields()
public async Task SenseDiffShouldUpdateAllFields()
{
var before = new Sense();
var after = _autoFaker.Generate<Sense>();
var after = AutoFaker.Generate<Sense>();
var senseDiffToUpdate = await SenseSync.SenseDiffToUpdate(before, after);
ArgumentNullException.ThrowIfNull(senseDiffToUpdate);
senseDiffToUpdate.Apply(before);
Expand All @@ -44,7 +44,7 @@ public async Task SenseDiffShouldUpdateAllFields()
public void ExampleSentenceDiffShouldUpdateAllFields()
{
var before = new ExampleSentence();
var after = _autoFaker.Generate<ExampleSentence>();
var after = AutoFaker.Generate<ExampleSentence>();
var exampleSentenceDiffToUpdate = ExampleSentenceSync.DiffToUpdate(before, after);
ArgumentNullException.ThrowIfNull(exampleSentenceDiffToUpdate);
exampleSentenceDiffToUpdate.Apply(before);
Expand Down
4 changes: 2 additions & 2 deletions backend/FwLite/LcmCrdt.Tests/DataModelSnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace LcmCrdt.Tests;

public class DataModelSnapshotTests : IAsyncLifetime
{
private static AutoFaker _faker = new AutoFaker(new AutoFakerConfig()
private static readonly AutoFaker Faker = new AutoFaker(new AutoFakerConfig()
{
Overrides = [new MultiStringOverride(), new WritingSystemIdOverride()]
});
Expand Down Expand Up @@ -90,7 +90,7 @@ public void VerifyIObjectWithIdsMatchAdapterGetObjectTypeName()
foreach (var jsonDerivedType in types)
{
var typeDiscriminator = jsonDerivedType.TypeDiscriminator.Should().BeOfType<string>().Subject;
var obj = _faker.Generate(jsonDerivedType.DerivedType);
var obj = Faker.Generate(jsonDerivedType.DerivedType);
new MiniLcmCrdtAdapter((IObjectWithId)obj).GetObjectTypeName().Should().Be(typeDiscriminator);
}
}
Expand Down
4 changes: 2 additions & 2 deletions backend/FwLite/LcmCrdt.Tests/EntityCopyMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace LcmCrdt.Tests;

public class EntityCopyMethodTests
{
private readonly AutoFaker _autoFaker = new(new AutoFakerConfig()
private static readonly AutoFaker AutoFaker = new(new AutoFakerConfig()
{
Overrides = [new MultiStringOverride(), new WritingSystemIdOverride()]
});
Expand All @@ -35,7 +35,7 @@ public static IEnumerable<object[]> GetEntityTypes()
public void EntityCopyMethodShouldCopyAllFields(Type type)
{
type.IsAssignableTo(typeof(IObjectWithId)).Should().BeTrue();
var entity = (IObjectWithId) _autoFaker.Generate(type);
var entity = (IObjectWithId) AutoFaker.Generate(type);
var copy = entity.Copy();
copy.Should().BeEquivalentTo(entity, options => options.IncludingAllRuntimeProperties());
}
Expand Down
2 changes: 1 addition & 1 deletion backend/FwLite/LcmCrdt.Tests/LcmCrdt.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="2.1.278" />
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="3.0.410" />
<PackageReference Include="Verify.Xunit" Version="27.0.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down
2 changes: 1 addition & 1 deletion backend/FwLite/MiniLcm.Tests/MiniLcm.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="2.1.278"/>
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="3.0.410" />
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion backend/FwLite/MiniLcm.Tests/MiniLcmTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace MiniLcm.Tests;
public abstract class MiniLcmTestBase : IAsyncLifetime
{

protected readonly AutoFaker AutoFaker = new(builder =>
protected static readonly AutoFaker AutoFaker = new(builder =>
builder.WithOverride(new MultiStringOverride(["en"]))
.WithOverride(new ObjectWithIdOverride())
);
Expand Down

0 comments on commit dde589b

Please sign in to comment.