Skip to content

Commit

Permalink
Upgrade to FluentAssertions 7-prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Nov 22, 2024
1 parent 610826f commit bbd1064
Show file tree
Hide file tree
Showing 34 changed files with 117 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<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="FluentAssertions" Version="7.0.0-alpha.5"/>
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
56 changes: 28 additions & 28 deletions backend/FwLite/FwDataMiniLcmBridge.Tests/UpdateComplexFormsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Add(e => e.Components,
ComplexFormComponent.FromEntries(complexForm, component)));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
entry!.Components.Should()
entry.Should().NotBeNull();
entry.Components.Should()
.ContainSingle(c => c.ComponentEntryId == component.Id && c.ComplexFormEntryId == complexForm.Id);
}

Expand Down Expand Up @@ -62,8 +62,8 @@ public async Task CanRemoveComponentFromExistingEntry()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Remove(e => e.Components, 0));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
entry!.Components.Should().BeEmpty();
entry.Should().NotBeNull();
entry.Components.Should().BeEmpty();
}

[Fact]
Expand Down Expand Up @@ -91,8 +91,8 @@ public async Task CanChangeComponentId()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Set(e => e.Components[0].ComponentEntryId, component2.Id));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
var complexFormComponent = entry!.Components.Should().ContainSingle().Subject;
entry.Should().NotBeNull();
var complexFormComponent = entry.Components.Should().ContainSingle().Subject;
complexFormComponent.ComponentEntryId.Should().Be(component2.Id);
}

Expand Down Expand Up @@ -126,8 +126,8 @@ public async Task CanChangeComponentSenseId()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Set(e => e.Components[0].ComponentSenseId, component2SenseId));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
var complexFormComponent = entry!.Components.Should().ContainSingle().Subject;
entry.Should().NotBeNull();
var complexFormComponent = entry.Components.Should().ContainSingle().Subject;
complexFormComponent.ComponentEntryId.Should().Be(component2.Id);
complexFormComponent.ComponentSenseId.Should().Be(component2SenseId);
}
Expand Down Expand Up @@ -162,8 +162,8 @@ public async Task CanChangeComponentSenseIdToNull()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Set(e => e.Components[0].ComponentSenseId, null));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
entry!.Components.Should()
entry.Should().NotBeNull();
entry.Components.Should()
.ContainSingle(c => c.ComponentEntryId == component2.Id && c.ComponentSenseId == null);
}

Expand Down Expand Up @@ -192,8 +192,8 @@ public async Task CanChangeComplexFormId()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Set(e => e.Components[0].ComplexFormEntryId, complexForm2.Id));
var entry = await _api.GetEntry(complexForm2.Id);
entry.ShouldNotBeNull();
var complexFormComponent = entry!.Components.Should().ContainSingle().Subject;
entry.Should().NotBeNull();
var complexFormComponent = entry.Components.Should().ContainSingle().Subject;
complexFormComponent.ComponentEntryId.Should().Be(component1.Id);
}

Expand All @@ -207,8 +207,8 @@ await _api.UpdateEntry(component.Id,
new UpdateObjectInput<Entry>().Add(e => e.ComplexForms,
ComplexFormComponent.FromEntries(complexForm, component)));
var entry = await _api.GetEntry(component.Id);
entry.ShouldNotBeNull();
entry!.ComplexForms.Should()
entry.Should().NotBeNull();
entry.ComplexForms.Should()
.ContainSingle(c => c.ComponentEntryId == component.Id && c.ComplexFormEntryId == complexForm.Id);
}

Expand Down Expand Up @@ -236,8 +236,8 @@ await _api.CreateEntry(new()
await _api.UpdateEntry(component.Id,
new UpdateObjectInput<Entry>().Remove(e => e.ComplexForms, 0));
var entry = await _api.GetEntry(component.Id);
entry.ShouldNotBeNull();
entry!.ComplexForms.Should().BeEmpty();
entry.Should().NotBeNull();
entry.ComplexForms.Should().BeEmpty();
}

[Fact]
Expand Down Expand Up @@ -265,8 +265,8 @@ await _api.CreateEntry(new()
await _api.UpdateEntry(component1.Id,
new UpdateObjectInput<Entry>().Set(e => e.ComplexForms[0].ComplexFormEntryId, complexForm2.Id));
var entry = await _api.GetEntry(component1.Id);
entry.ShouldNotBeNull();
var complexFormComponent = entry!.ComplexForms.Should().ContainSingle().Subject;
entry.Should().NotBeNull();
var complexFormComponent = entry.ComplexForms.Should().ContainSingle().Subject;
complexFormComponent.ComplexFormEntryId.Should().Be(complexForm2.Id);
}

Expand Down Expand Up @@ -295,8 +295,8 @@ await _api.CreateEntry(new()
await _api.UpdateEntry(component1.Id,
new UpdateObjectInput<Entry>().Set(e => e.ComplexForms[0].ComponentEntryId, component2.Id));
var entry = await _api.GetEntry(component2.Id);
entry.ShouldNotBeNull();
var complexFormComponent = entry!.ComplexForms.Should().ContainSingle().Subject;
entry.Should().NotBeNull();
var complexFormComponent = entry.ComplexForms.Should().ContainSingle().Subject;
complexFormComponent.ComponentEntryId.Should().Be(component2.Id);
complexFormComponent.ComplexFormEntryId.Should().Be(complexFormId);
}
Expand Down Expand Up @@ -337,8 +337,8 @@ await _api.CreateEntry(new()
await _api.UpdateEntry(component1.Id,
new UpdateObjectInput<Entry>().Set(e => e.ComplexForms[0].ComponentSenseId, component1SenseId2));
var entry = await _api.GetEntry(component1.Id);
entry.ShouldNotBeNull();
var complexFormComponent = entry!.ComplexForms.Should().ContainSingle().Subject;
entry.Should().NotBeNull();
var complexFormComponent = entry.ComplexForms.Should().ContainSingle().Subject;
complexFormComponent.ComponentEntryId.Should().Be(componentId1);
complexFormComponent.ComponentSenseId.Should().Be(component1SenseId2);
}
Expand All @@ -352,8 +352,8 @@ public async Task CanAddComplexFormType()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Add(e => e.ComplexFormTypes, complexFormType));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
entry!.ComplexFormTypes.Should().ContainSingle(c => c.Id == complexFormType.Id);
entry.Should().NotBeNull();
entry.ComplexFormTypes.Should().ContainSingle(c => c.Id == complexFormType.Id);
}

[Fact]
Expand All @@ -368,8 +368,8 @@ public async Task CanRemoveComplexFormType()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Remove(e => e.ComplexFormTypes, 0));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
entry!.ComplexFormTypes.Should().BeEmpty();
entry.Should().NotBeNull();
entry.ComplexFormTypes.Should().BeEmpty();
}

[Fact]
Expand All @@ -381,7 +381,7 @@ public async Task CanChangeComplexFormType()
await _api.UpdateEntry(complexForm.Id,
new UpdateObjectInput<Entry>().Set(e => e.ComplexFormTypes[0].Id, complexFormType2.Id));
var entry = await _api.GetEntry(complexForm.Id);
entry.ShouldNotBeNull();
entry!.ComplexFormTypes.Should().ContainSingle().Which.Id.Should().Be(complexFormType2.Id);
entry.Should().NotBeNull();
entry.ComplexFormTypes.Should().ContainSingle().Which.Id.Should().Be(complexFormType2.Id);
}
}
8 changes: 4 additions & 4 deletions backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task CanSyncRandomEntries()
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.ShouldNotBeNull();
actual.Should().NotBeNull();
actual.Should().BeEquivalentTo(after, options => options);
}

Expand Down Expand Up @@ -56,7 +56,7 @@ public async Task CanChangeComplexFormVisSync_Components()
await EntrySync.Sync(after, complexForm, _fixture.CrdtApi);

var actual = await _fixture.CrdtApi.GetEntry(after.Id);
actual.ShouldNotBeNull();
actual.Should().NotBeNull();
actual.Should().BeEquivalentTo(after, options => options);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ public async Task CanChangeComplexFormViaSync_ComplexForms()
await EntrySync.Sync(after, component, _fixture.CrdtApi);

var actual = await _fixture.CrdtApi.GetEntry(after.Id);
actual.ShouldNotBeNull();
actual.Should().NotBeNull();
actual.Should().BeEquivalentTo(after, options => options);
}

Expand All @@ -102,7 +102,7 @@ public async Task CanChangeComplexFormTypeViaSync()
await EntrySync.Sync(after, entry, _fixture.CrdtApi);

var actual = await _fixture.CrdtApi.GetEntry(after.Id);
actual.ShouldNotBeNull();
actual.Should().NotBeNull();
actual.Should().BeEquivalentTo(after, options => options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PackageReference>
<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="FluentAssertions" Version="7.0.0-alpha.5"/>
<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">
Expand Down
28 changes: 14 additions & 14 deletions backend/FwLite/LcmCrdt.Tests/Changes/ComplexFormTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public async Task AddComplexFormType()
var change = new AddComplexFormTypeChange(complexEntry.Id,complexFormType);
await fixture.DataModel.AddChange(Guid.NewGuid(), change);
complexEntry = await fixture.Api.GetEntry(complexEntry.Id);
complexEntry.ShouldNotBeNull();
complexEntry!.ComplexFormTypes.Should().ContainSingle().Which.Id.Should().Be(change.ComplexFormType.Id);
complexEntry.Should().NotBeNull();
complexEntry.ComplexFormTypes.Should().ContainSingle().Which.Id.Should().Be(change.ComplexFormType.Id);
}

[Fact]
Expand All @@ -32,15 +32,15 @@ await fixture.DataModel.AddChange(
new AddComplexFormTypeChange(complexEntry.Id, complexFormType)
);
complexEntry = await fixture.Api.GetEntry(complexEntry.Id);
complexEntry.ShouldNotBeNull();
complexEntry!.ComplexFormTypes.Should().ContainSingle().Which.Id.Should().Be(complexFormType.Id);
complexEntry.Should().NotBeNull();
complexEntry.ComplexFormTypes.Should().ContainSingle().Which.Id.Should().Be(complexFormType.Id);
await fixture.DataModel.AddChange(
Guid.NewGuid(),
new RemoveComplexFormTypeChange(complexEntry.Id, complexFormType.Id)
);
complexEntry = await fixture.Api.GetEntry(complexEntry.Id);
complexEntry.ShouldNotBeNull();
complexEntry!.ComplexFormTypes.Should().BeEmpty();
complexEntry.Should().NotBeNull();
complexEntry.ComplexFormTypes.Should().BeEmpty();
}

[Fact]
Expand All @@ -54,13 +54,13 @@ public async Task AddEntryComponent()
await fixture.DataModel.AddChange(Guid.NewGuid(), new AddEntryComponentChange(ComplexFormComponent.FromEntries(complexEntry, coatEntry)));
await fixture.DataModel.AddChange(Guid.NewGuid(), new AddEntryComponentChange(ComplexFormComponent.FromEntries(complexEntry, rackEntry)));
complexEntry = await fixture.Api.GetEntry(complexEntry.Id);
complexEntry.ShouldNotBeNull();
complexEntry!.Components.Should().ContainSingle(e => e.ComponentEntryId == coatEntry.Id);
complexEntry.Should().NotBeNull();
complexEntry.Components.Should().ContainSingle(e => e.ComponentEntryId == coatEntry.Id);
complexEntry.Components.Should().ContainSingle(e => e.ComponentEntryId == rackEntry.Id);

coatEntry = await fixture.Api.GetEntry(coatEntry.Id);
coatEntry.ShouldNotBeNull();
coatEntry!.ComplexForms.Should().ContainSingle(e => e.ComplexFormEntryId == complexEntry.Id);
coatEntry.Should().NotBeNull();
coatEntry.ComplexForms.Should().ContainSingle(e => e.ComplexFormEntryId == complexEntry.Id);
}

[Fact]
Expand All @@ -73,12 +73,12 @@ public async Task DeleteEntryComponent()
await fixture.DataModel.AddChange(Guid.NewGuid(), new AddEntryComponentChange(ComplexFormComponent.FromEntries(complexEntry, coatEntry)));
await fixture.DataModel.AddChange(Guid.NewGuid(), new AddEntryComponentChange(ComplexFormComponent.FromEntries(complexEntry, rackEntry)));
complexEntry = await fixture.Api.GetEntry(complexEntry.Id);
complexEntry.ShouldNotBeNull();
var component = complexEntry!.Components.First();
complexEntry.Should().NotBeNull();
var component = complexEntry.Components.First();

await fixture.DataModel.AddChange(Guid.NewGuid(), new DeleteChange<ComplexFormComponent>(component.Id));
complexEntry = await fixture.Api.GetEntry(complexEntry.Id);
complexEntry.ShouldNotBeNull();
complexEntry!.Components.Should().NotContain(c => c.Id == component.Id);
complexEntry.Should().NotBeNull();
complexEntry.Components.Should().NotContain(c => c.Id == component.Id);
}
}
2 changes: 1 addition & 1 deletion backend/FwLite/LcmCrdt.Tests/DataModelSnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void VerifyIObjectWithIdsMatchAdapterGetObjectTypeName()
{
foreach (var jsonDerivedType in types)
{
var typeDiscriminator = jsonDerivedType.TypeDiscriminator.ShouldBeOfType<string>();
var typeDiscriminator = jsonDerivedType.TypeDiscriminator.Should().BeOfType<string>().Subject;
var obj = Faker.Generate(jsonDerivedType.DerivedType);
new MiniLcmCrdtAdapter((IObjectWithId)obj).GetObjectTypeName().Should().Be(typeDiscriminator);
}
Expand Down
6 changes: 3 additions & 3 deletions backend/FwLite/LcmCrdt.Tests/JsonPatchEntryRewriteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ChangesFromJsonPatch_AddComponentMakesAddEntryComponentChange()
patch.Add(entry => entry.Components, ComplexFormComponent.FromEntries(_entry, componentEntry));
var changes = _entry.ToChanges(patch);
var addEntryComponentChange =
changes.Should().ContainSingle().Which.ShouldBeOfType<AddEntryComponentChange>();
changes.Should().ContainSingle().Which.Should().BeOfType<AddEntryComponentChange>().Subject;
addEntryComponentChange.ComplexFormEntryId.Should().Be(_entry.Id);
addEntryComponentChange.ComponentEntryId.Should().Be(componentEntry.Id);
addEntryComponentChange.ComponentHeadword.Should().Be(componentEntry.Headword());
Expand Down Expand Up @@ -81,7 +81,7 @@ public void ChangesFromJsonPatch_AddComplexFormMakesAddEntryComponentChange()
patch.Add(entry => entry.ComplexForms, ComplexFormComponent.FromEntries(_entry, componentEntry));
var changes = componentEntry.ToChanges(patch);
var addEntryComponentChange =
changes.Should().ContainSingle().Which.ShouldBeOfType<AddEntryComponentChange>();
changes.Should().ContainSingle().Which.Should().BeOfType<AddEntryComponentChange>().Subject;
addEntryComponentChange.ComplexFormEntryId.Should().Be(_entry.Id);
addEntryComponentChange.ComponentEntryId.Should().Be(componentEntry.Id);
addEntryComponentChange.ComponentHeadword.Should().Be(componentEntry.Headword());
Expand Down Expand Up @@ -145,7 +145,7 @@ public void ChangesFromJsonPatch_AddComplexFormTypeMakesAddComplexFormTypeChange
patch.Add(entry => entry.ComplexFormTypes, complexFormType);
var changes = _entry.ToChanges(patch);
var addComplexFormTypeChange =
changes.Should().ContainSingle().Which.ShouldBeOfType<AddComplexFormTypeChange>();
changes.Should().ContainSingle().Which.Should().BeOfType<AddComplexFormTypeChange>().Subject;
addComplexFormTypeChange.EntityId.Should().Be(_entry.Id);
addComplexFormTypeChange.ComplexFormType.Should().Be(complexFormType);
}
Expand Down
2 changes: 1 addition & 1 deletion backend/FwLite/LcmCrdt.Tests/JsonPatchSenseRewriteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void JsonPatchChangeRewriteDoesNotReturnEmptyPatchChanges()
var changes = _sense.ToChanges(_patchDocument).ToArray();

var setPartOfSpeechChange = changes.Should().ContainSingle()
.Subject.ShouldBeOfType<SetPartOfSpeechChange>();
.Subject.Should().BeOfType<SetPartOfSpeechChange>().Subject;
setPartOfSpeechChange.EntityId.Should().Be(_sense.Id);
setPartOfSpeechChange.PartOfSpeechId.Should().Be(newPartOfSpeechId);
}
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 @@ -16,7 +16,7 @@
</PackageReference>
<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="FluentAssertions" Version="7.0.0-alpha.5"/>
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="3.0.410" />
<PackageReference Include="Verify.Xunit" Version="27.0.1" />
<PackageReference Include="xunit" Version="2.9.2" />
Expand Down
4 changes: 2 additions & 2 deletions backend/FwLite/LcmCrdt.Tests/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void CanDeserializeMultiString()
Values = { { "en", "test" } }
};
var actualMs = JsonSerializer.Deserialize<MultiString>(json);
actualMs.ShouldNotBeNull();
actualMs!.Values.Should().ContainKey("en");
actualMs.Should().NotBeNull();
actualMs.Values.Should().ContainKey("en");
actualMs.Should().BeEquivalentTo(expectedMs);
}

Expand Down
6 changes: 3 additions & 3 deletions backend/FwLite/MiniLcm.Tests/BasicApiTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ public async Task SearchEntries_MatchesGloss()
public async Task GetEntry()
{
var entry = await Api.GetEntry(Entry1Id);
entry.ShouldNotBeNull();
entry!.LexemeForm.Values.Should().NotBeEmpty();
entry.Should().NotBeNull();
entry.LexemeForm.Values.Should().NotBeEmpty();
var sense = entry.Senses.Should()
.NotBeEmpty($"because '{entry.LexemeForm.Values.First().Value}' should have a sense").And.Subject.First();
sense.Gloss.Values.Should().NotBeEmpty();
Expand Down Expand Up @@ -275,7 +275,7 @@ public async Task CreateEntry()
}
]
});
entry.ShouldNotBeNull();
entry.Should().NotBeNull();
entry.LexemeForm.Values["en"].Should().Be("Kevin");
entry.LiteralMeaning.Values["en"].Should().Be("Kevin");
entry.CitationForm.Values["en"].Should().Be("Kevin");
Expand Down
Loading

0 comments on commit bbd1064

Please sign in to comment.