-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* always using DoUsingNewOrCurrentUOW as we've got a lot of recursive calls now * allow defining copy which returns the correct type instead of IObjectWithId * change UpdateEntry to use before and after instead of depending on Version * fix test issue due to parts of speech and domains not being created when an entry is created, fix issue with ordering of adding complex forms to an entry
- Loading branch information
Showing
31 changed files
with
694 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 3 additions & 1 deletion
4
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/BasicApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/UpdateEntryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using FwDataMiniLcmBridge.Tests.Fixtures; | ||
|
||
namespace FwDataMiniLcmBridge.Tests.MiniLcmTests; | ||
|
||
[Collection(ProjectLoaderFixture.Name)] | ||
public class UpdateEntryTests(ProjectLoaderFixture fixture) : UpdateEntryTestsBase | ||
{ | ||
protected override Task<IMiniLcmApi> NewApi() | ||
{ | ||
return Task.FromResult<IMiniLcmApi>(fixture.NewProjectApi("update-entry-test", "en", "en")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
backend/FwLite/FwDataMiniLcmBridge/Api/VersionInvalidException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace FwDataMiniLcmBridge.Api; | ||
|
||
public class VersionInvalidException(string type, Exception? innerException = null) : Exception( | ||
$"version of {type} is invalid, it has been changed since this version was fetched", | ||
innerException); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using FluentAssertions.Equivalency; | ||
using FwLiteProjectSync.Tests.Fixtures; | ||
using MiniLcm.Models; | ||
using MiniLcm.SyncHelpers; | ||
using MiniLcm.Tests.AutoFakerHelpers; | ||
using Soenneker.Utils.AutoBogus; | ||
|
||
namespace FwLiteProjectSync.Tests; | ||
|
||
public class EntrySyncTests : IClassFixture<SyncFixture> | ||
{ | ||
private readonly AutoFaker _autoFaker = new(builder => builder.WithOverride(new MultiStringOverride()).WithOverride(new ObjectWithIdOverride())); | ||
public EntrySyncTests(SyncFixture fixture) | ||
{ | ||
_fixture = fixture; | ||
} | ||
|
||
private readonly 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); | ||
await EntrySync.Sync(after, createdEntry, _fixture.CrdtApi); | ||
var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
actual.Should().NotBeNull(); | ||
actual.Should().BeEquivalentTo(after, options => options); | ||
} | ||
|
||
[Fact] | ||
public async Task CanChangeComplexFormVisSync_Components() | ||
{ | ||
var component1 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "component1" } } }); | ||
var component2 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "component2" } } }); | ||
var complexFormId = Guid.NewGuid(); | ||
var complexForm = await _fixture.CrdtApi.CreateEntry(new() | ||
{ | ||
Id = complexFormId, | ||
LexemeForm = { { "en", "complex form" } }, | ||
Components = | ||
[ | ||
new ComplexFormComponent() | ||
{ | ||
ComponentEntryId = component1.Id, | ||
ComponentHeadword = component1.Headword(), | ||
ComplexFormEntryId = complexFormId, | ||
ComplexFormHeadword = "complex form" | ||
} | ||
] | ||
}); | ||
Entry after = (Entry) complexForm.Copy(); | ||
after.Components[0].ComponentEntryId = component2.Id; | ||
after.Components[0].ComponentHeadword = component2.Headword(); | ||
|
||
await EntrySync.Sync(after, complexForm, _fixture.CrdtApi); | ||
|
||
var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
actual.Should().NotBeNull(); | ||
actual.Should().BeEquivalentTo(after, options => options); | ||
} | ||
|
||
[Fact] | ||
public async Task CanChangeComplexFormViaSync_ComplexForms() | ||
{ | ||
var complexForm1 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "complexForm1" } } }); | ||
var complexForm2 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "complexForm2" } } }); | ||
var componentId = Guid.NewGuid(); | ||
var component = await _fixture.CrdtApi.CreateEntry(new() | ||
{ | ||
Id = componentId, | ||
LexemeForm = { { "en", "component" } }, | ||
ComplexForms = | ||
[ | ||
new ComplexFormComponent() | ||
{ | ||
ComponentEntryId = componentId, | ||
ComponentHeadword = "component", | ||
ComplexFormEntryId = complexForm1.Id, | ||
ComplexFormHeadword = complexForm1.Headword() | ||
} | ||
] | ||
}); | ||
Entry after = (Entry) component.Copy(); | ||
after.ComplexForms[0].ComplexFormEntryId = complexForm2.Id; | ||
after.ComplexForms[0].ComplexFormHeadword = complexForm2.Headword(); | ||
|
||
await EntrySync.Sync(after, component, _fixture.CrdtApi); | ||
|
||
var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
actual.Should().NotBeNull(); | ||
actual.Should().BeEquivalentTo(after, options => options); | ||
} | ||
|
||
[Fact] | ||
public async Task CanChangeComplexFormTypeViaSync() | ||
{ | ||
var entry = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "complexForm1" } } }); | ||
var complexFormType = await _fixture.CrdtApi.GetComplexFormTypes().FirstAsync(); | ||
var after = (Entry) entry.Copy(); | ||
after.ComplexFormTypes = [complexFormType]; | ||
await EntrySync.Sync(after, entry, _fixture.CrdtApi); | ||
|
||
var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
actual.Should().NotBeNull(); | ||
actual.Should().BeEquivalentTo(after, options => options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.