Skip to content

Commit

Permalink
Address review comments so far
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Jan 7, 2025
1 parent 04b8b26 commit 87b2f8b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
26 changes: 9 additions & 17 deletions backend/FwLite/MiniLcm.Tests/Validators/EntryValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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"}} };
Expand All @@ -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"}} };
Expand All @@ -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"}} };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
8 changes: 4 additions & 4 deletions backend/FwLite/MiniLcm/Validators/EntryValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentValidation;
using MiniLcm.Models;

namespace MiniLcm.Validators;

Expand Down

0 comments on commit 87b2f8b

Please sign in to comment.