-
-
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.
- Loading branch information
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/ComplexFormComponentTests.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 ComplexFormComponentTests(ProjectLoaderFixture fixture): ComplexFormComponentTestsBase | ||
{ | ||
protected override Task<IMiniLcmApi> NewApi() | ||
{ | ||
return Task.FromResult<IMiniLcmApi>(fixture.NewProjectApi("complex-form-component-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
19 changes: 19 additions & 0 deletions
19
backend/FwLite/LcmCrdt.Tests/MiniLcmTests/ComplexFormComponentTests.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,19 @@ | ||
namespace LcmCrdt.Tests.MiniLcmTests; | ||
|
||
public class ComplexFormComponentTests : ComplexFormComponentTestsBase | ||
{ | ||
private readonly MiniLcmApiFixture _fixture = new(); | ||
|
||
protected override async Task<IMiniLcmApi> NewApi() | ||
{ | ||
await _fixture.InitializeAsync(); | ||
var api = _fixture.Api; | ||
return api; | ||
} | ||
|
||
public override async Task DisposeAsync() | ||
{ | ||
await base.DisposeAsync(); | ||
await _fixture.DisposeAsync(); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
backend/FwLite/MiniLcm.Tests/ComplexFormComponentTestsBase.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,77 @@ | ||
using MiniLcm.Models; | ||
|
||
namespace MiniLcm.Tests; | ||
|
||
public abstract class ComplexFormComponentTestsBase : MiniLcmTestBase | ||
{ | ||
private readonly Guid _complexFormEntryId = Guid.NewGuid(); | ||
private readonly Guid _componentEntryId = Guid.NewGuid(); | ||
private readonly Guid _componentSenseId1 = Guid.NewGuid(); | ||
private readonly Guid _componentSenseId2 = Guid.NewGuid(); | ||
private Entry _complexFormEntry = null!; | ||
private Entry _componentEntry = null!; | ||
|
||
public override async Task InitializeAsync() | ||
{ | ||
await base.InitializeAsync(); | ||
_complexFormEntry = await Api.CreateEntry(new() | ||
{ | ||
Id = _complexFormEntryId, | ||
LexemeForm = { { "en", "complex form" } } | ||
}); | ||
_componentEntry = await Api.CreateEntry(new() | ||
{ | ||
Id = _componentEntryId, | ||
LexemeForm = { { "en", "component" } }, | ||
Senses = | ||
[ | ||
new Sense | ||
{ | ||
Id = _componentSenseId1, | ||
Gloss = { { "en", "component sense 1" } } | ||
}, | ||
new Sense | ||
{ | ||
Id = _componentSenseId2, | ||
Gloss = { { "en", "component sense 2" } } | ||
} | ||
] | ||
}); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateComplexFormComponent_Works() | ||
{ | ||
var component = await Api.CreateComplexFormComponent(ComplexFormComponent.FromEntries(_complexFormEntry, _componentEntry)); | ||
component.ComplexFormEntryId.Should().Be(_complexFormEntryId); | ||
component.ComponentEntryId.Should().Be(_componentEntryId); | ||
component.ComponentSenseId.Should().BeNull(); | ||
component.ComplexFormHeadword.Should().Be("complex form"); | ||
component.ComponentHeadword.Should().Be("component"); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateComplexFormComponent_WorksWithSense() | ||
{ | ||
var component = await Api.CreateComplexFormComponent(ComplexFormComponent.FromEntries(_complexFormEntry, _componentEntry, _componentSenseId1)); | ||
component.ComplexFormEntryId.Should().Be(_complexFormEntryId); | ||
component.ComponentEntryId.Should().Be(_componentEntryId); | ||
component.ComponentSenseId.Should().Be(_componentSenseId1); | ||
component.ComplexFormHeadword.Should().Be("complex form"); | ||
component.ComponentHeadword.Should().Be("component"); | ||
} | ||
|
||
[Fact] | ||
public async Task CreateComplexFormComponent_CanCreateMultipleComponentSenses() | ||
{ | ||
var component1 = await Api.CreateComplexFormComponent(ComplexFormComponent.FromEntries(_complexFormEntry, _componentEntry, _componentSenseId1)); | ||
component1.ComplexFormEntryId.Should().Be(_complexFormEntryId); | ||
component1.ComponentEntryId.Should().Be(_componentEntryId); | ||
component1.ComponentSenseId.Should().Be(_componentSenseId1); | ||
|
||
var component2 = await Api.CreateComplexFormComponent(ComplexFormComponent.FromEntries(_complexFormEntry, _componentEntry, _componentSenseId2)); | ||
component2.ComplexFormEntryId.Should().Be(_complexFormEntryId); | ||
component2.ComponentEntryId.Should().Be(_componentEntryId); | ||
component2.ComponentSenseId.Should().Be(_componentSenseId2); | ||
} | ||
} |