Skip to content

Commit

Permalink
write test for creating a complex form type, upgrade lcm so we can us…
Browse files Browse the repository at this point in the history
…e the new Create(Guid id) api when creating the complex form type (#1223)
  • Loading branch information
hahn-kev authored Nov 12, 2024
1 parent f0dc3e6 commit fa56386
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
5 changes: 2 additions & 3 deletions backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,17 @@ private ComplexFormType ToComplexFormType(ICmPossibility t)

public Task<ComplexFormType> CreateComplexFormType(ComplexFormType complexFormType)
{
if (complexFormType.Id != default) throw new InvalidOperationException("Complex form type id must be empty");
if (complexFormType.Id == default) complexFormType.Id = Guid.NewGuid();
UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Create complex form type",
"Remove complex form type",
Cache.ActionHandlerAccessor,
() =>
{
var lexComplexFormType = Cache.ServiceLocator
.GetInstance<ILexEntryTypeFactory>()
.Create();
.Create(complexFormType.Id);
ComplexFormTypes.PossibilitiesOS.Add(lexComplexFormType);
UpdateLcmMultiString(lexComplexFormType.Name, complexFormType.Name);
complexFormType.Id = lexComplexFormType.Guid;
});
return Task.FromResult(ToComplexFormType(ComplexFormTypes.PossibilitiesOS.Single(c => c.Guid == complexFormType.Id)));
}
Expand Down
4 changes: 2 additions & 2 deletions backend/FwLite/FwDataMiniLcmBridge/FwDataMiniLcmBridge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="SIL.Core" Version="14.2.0-beta0009" />
<PackageReference Include="SIL.Core" Version="14.2.0-beta0022" />
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="72.1.0.3" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
<PackageReference Include="SIL.LCModel" Version="11.0.0-beta0100 " />
<PackageReference Include="SIL.LCModel" Version="11.0.0-beta0111" />
<PackageReference Include="structuremap.patched" Version="4.7.3" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public IAsyncEnumerable<ComplexFormType> GetComplexFormTypes()
return ComplexFormTypes.AsAsyncEnumerable();
}

public async Task<ComplexFormType> CreateComplexFormType(MiniLcm.Models.ComplexFormType complexFormType)
public async Task<ComplexFormType> CreateComplexFormType(ComplexFormType complexFormType)
{
if (complexFormType.Id == default) complexFormType.Id = Guid.NewGuid();
await dataModel.AddChange(ClientId, new CreateComplexFormType(complexFormType.Id, complexFormType.Name));
Expand Down
2 changes: 1 addition & 1 deletion backend/FwLite/LocalWebApp/LocalWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="icu.net" Version="2.10.1-beta.5" GeneratePathProperty="true" />
<PackageReference Include="icu.net" Version="3.0.0-beta.297" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.10" />
Expand Down
9 changes: 9 additions & 0 deletions backend/FwLite/MiniLcm.Tests/ComplexFormComponentTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,13 @@ public async Task CreateComplexFormComponent_CanCreateMultipleComponentSenses()
component2.ComponentEntryId.Should().Be(_componentEntryId);
component2.ComponentSenseId.Should().Be(_componentSenseId2);
}

[Fact]
public async Task CreateComplexFormType_Works()
{
var complexFormType = new ComplexFormType() { Id = Guid.NewGuid(), Name = new() { { "en", "test" } } };
await Api.CreateComplexFormType(complexFormType);
var types = await Api.GetComplexFormTypes().ToArrayAsync();
types.Should().ContainSingle(t => t.Id == complexFormType.Id);
}
}

0 comments on commit fa56386

Please sign in to comment.