diff --git a/backend/FwLite/MiniLcm.Tests/Validators/EntryValidatorTests.cs b/backend/FwLite/MiniLcm.Tests/Validators/EntryValidatorTests.cs index adf40dcdc..18eae12eb 100644 --- a/backend/FwLite/MiniLcm.Tests/Validators/EntryValidatorTests.cs +++ b/backend/FwLite/MiniLcm.Tests/Validators/EntryValidatorTests.cs @@ -62,14 +62,6 @@ public void Fails_WhenLexemeFormIsMissing() _validator.TestValidate(entry).ShouldHaveValidationErrorFor("LexemeForm"); } - [Fact] - public void Fails_WhenLexemeFormHasNoContent() - { - // Technically the same as Fails_WhenLexemeFormIsMissing -- should we combine them? - var entry = new Entry() { Id = Guid.NewGuid(), LexemeForm = new MultiString() }; - _validator.TestValidate(entry).ShouldHaveValidationErrorFor("LexemeForm"); - } - [Fact] public void Fails_WhenLexemeFormHasWsWithEmptyContent() { @@ -78,9 +70,9 @@ public void Fails_WhenLexemeFormHasWsWithEmptyContent() } [Theory] - [InlineData("CitationForm")] - [InlineData("LiteralMeaning")] - [InlineData("Note")] + [InlineData(nameof(Entry.CitationForm))] + [InlineData(nameof(Entry.LiteralMeaning))] + [InlineData(nameof(Entry.Note))] public void Succeeds_WhenNonEmptyFieldIsPresent(string fieldName) { var entry = new Entry() { Id = Guid.NewGuid(), LexemeForm = new MultiString(){{"en", "lexeme"}} }; @@ -89,9 +81,9 @@ public void Succeeds_WhenNonEmptyFieldIsPresent(string fieldName) } [Theory] - [InlineData("CitationForm")] - [InlineData("LiteralMeaning")] - [InlineData("Note")] + [InlineData(nameof(Entry.CitationForm))] + [InlineData(nameof(Entry.LiteralMeaning))] + [InlineData(nameof(Entry.Note))] public void Succeeds_WhenNonEmptyFieldHasNoContent(string fieldName) { var entry = new Entry() { Id = Guid.NewGuid(), LexemeForm = new MultiString(){{"en", "lexeme"}} }; @@ -100,9 +92,9 @@ public void Succeeds_WhenNonEmptyFieldHasNoContent(string fieldName) } [Theory] - [InlineData("CitationForm")] - [InlineData("LiteralMeaning")] - [InlineData("Note")] + [InlineData(nameof(Entry.CitationForm))] + [InlineData(nameof(Entry.LiteralMeaning))] + [InlineData(nameof(Entry.Note))] public void Fails_WhenNonEmptyFieldHasWsWithEmptyContent(string fieldName) { var entry = new Entry() { Id = Guid.NewGuid(), LexemeForm = new MultiString(){{"en", "lexeme"}} }; diff --git a/backend/FwLite/MiniLcm.Tests/Validators/ExampleSentenceValidatorTests.cs b/backend/FwLite/MiniLcm.Tests/Validators/ExampleSentenceValidatorTests.cs index c9c2223c0..d4f81d11c 100644 --- a/backend/FwLite/MiniLcm.Tests/Validators/ExampleSentenceValidatorTests.cs +++ b/backend/FwLite/MiniLcm.Tests/Validators/ExampleSentenceValidatorTests.cs @@ -35,14 +35,6 @@ public void Fails_WhenSentenceIsMissing() _validator.TestValidate(example).ShouldHaveValidationErrorFor("Sentence"); } - [Fact] - public void Fails_WhenSentenceHasNoContent() - { - // Technically the same as Fails_WhenSentenceIsMissing -- should we combine them? - var example = new ExampleSentence() { Id = Guid.NewGuid(), Sentence = new MultiString() }; - _validator.TestValidate(example).ShouldHaveValidationErrorFor("Sentence"); - } - [Fact] public void Fails_WhenSentenceHasWsWithEmptyContent() { diff --git a/backend/FwLite/MiniLcm/Validators/EntryValidator.cs b/backend/FwLite/MiniLcm/Validators/EntryValidator.cs index 08d47b594..e2cc980fb 100644 --- a/backend/FwLite/MiniLcm/Validators/EntryValidator.cs +++ b/backend/FwLite/MiniLcm/Validators/EntryValidator.cs @@ -25,21 +25,21 @@ public EntryValidator() private bool NotBeComponentSelfReference(Entry entry, ComplexFormComponent component) { - return component.ComponentEntryId != entry.Id; + return component.ComponentEntryId != entry.Id || component.ComponentEntryId == Guid.Empty; } private bool HaveCorrectComponentEntryReference(Entry entry, ComplexFormComponent component) { - return component.ComplexFormEntryId == entry.Id; + return component.ComplexFormEntryId == entry.Id || component.ComplexFormEntryId == Guid.Empty; } private bool NotBeComplexFormSelfReference(Entry entry, ComplexFormComponent component) { - return component.ComplexFormEntryId != entry.Id; + return component.ComplexFormEntryId != entry.Id || component.ComplexFormEntryId == Guid.Empty; } private bool HaveCorrectComplexFormEntryReference(Entry entry, ComplexFormComponent component) { - return component.ComponentEntryId == entry.Id; + return component.ComponentEntryId == entry.Id || component.ComponentEntryId == Guid.Empty; } } diff --git a/backend/FwLite/MiniLcm/Validators/PartOfSpeechIdValidator.cs b/backend/FwLite/MiniLcm/Validators/PartOfSpeechIdValidator.cs index 7bac0323b..20fa960f5 100644 --- a/backend/FwLite/MiniLcm/Validators/PartOfSpeechIdValidator.cs +++ b/backend/FwLite/MiniLcm/Validators/PartOfSpeechIdValidator.cs @@ -1,5 +1,4 @@ using FluentValidation; -using MiniLcm.Models; namespace MiniLcm.Validators;