Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FwDataMiniLcmBridge.Api;
using FwDataMiniLcmBridge.Tests.Fixtures;
using MiniLcm.Models;
using SIL.LCModel;
using SIL.LCModel.Infrastructure;

namespace FwDataMiniLcmBridge.Tests.MiniLcmTests;
Expand Down Expand Up @@ -81,4 +82,31 @@ public async Task SetPartOfSpeech_WithNullMorphoSyntaxAnalysisRA_ToNull()
retrievedEntry.Should().NotBeNull();
retrievedEntry!.PartOfSpeechId.Should().BeNull();
}

[Fact]
public async Task GetPartsOfSpeech_DoesNotReturnReversalIndexPos()
{
// Arrange
var fwApi = (FwDataMiniLcmApi)BaseApi;
var reversalIndexRepository = fwApi.Cache.ServiceLocator.GetInstance<IReversalIndexRepository>();
var analysisWs = fwApi.Cache.DefaultAnalWs;

var reversalPosGuid = Guid.NewGuid();
UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Create Reversal Index POS",
"Remove Reversal Index POS",
fwApi.Cache.ServiceLocator.ActionHandler,
() =>
{
var reversalIndex = reversalIndexRepository.FindOrCreateIndexForWs(analysisWs);
var posFactory = fwApi.Cache.ServiceLocator.GetInstance<IPartOfSpeechFactory>();
var reversalPos = posFactory.Create(reversalPosGuid, reversalIndex.PartsOfSpeechOA);
reversalPos.Name.set_String(analysisWs, "Reversal Test POS");
});

// Act
var partsOfSpeech = await Api.GetPartsOfSpeech().ToArrayAsync();

// Assert
partsOfSpeech.Should().NotContain(pos => pos.Id == reversalPosGuid);
}
}
3 changes: 1 addition & 2 deletions backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ void MoveWs(CoreWritingSystemDefinition ws,

public IAsyncEnumerable<PartOfSpeech> GetPartsOfSpeech()
{
return PartOfSpeechRepository
.AllInstances()
return Cache.LangProject.AllPartsOfSpeech
.OrderBy(p => p.Name.BestAnalysisAlternative.Text)
.ToAsyncEnumerable()
.Select(FromLcmPartOfSpeech);
Expand Down
8 changes: 8 additions & 0 deletions backend/FwLite/FwLiteProjectSync.Tests/SyncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ public async Task DisposeAsync()
{
await _fixture.CrdtApi.DeleteEntry(entry.Id);
}
await foreach (var pos in _fixture.FwDataApi.GetPartsOfSpeech())
{
await _fixture.FwDataApi.DeletePartOfSpeech(pos.Id);
}
foreach (var pos in await _fixture.CrdtApi.GetPartsOfSpeech().ToArrayAsync())
{
await _fixture.CrdtApi.DeletePartOfSpeech(pos.Id);
}
}

public SyncTests(SyncFixture fixture)
Expand Down
Loading