public async Task Should_not_add_error_if_string_value_not_found_but_in_optimized_mode() { var sut = new UniqueValidator(Check(DomainId.NewGuid())); await sut.ValidateAsync(null, errors); Assert.Empty(errors); }
public async Task Should_not_add_error_if_value_is_null() { var sut = new UniqueValidator(FoundDuplicates(DomainId.NewGuid())); await sut.ValidateAsync(null, errors); Assert.Empty(errors); }
public async Task Should_not_add_error_if_double_value_found_with_same_content_id() { var ctx = ValidationTestExtensions.CreateContext(); var sut = new UniqueValidator(Check(ctx.ContentId)); await sut.ValidateAsync(12.5, ctx, ValidationTestExtensions.CreateFormatter(errors)); Assert.Empty(errors); }
public async Task Should_not_add_error_if_double_value_found() { var sut = new UniqueValidator(); var filter = string.Empty; await sut.ValidateAsync(12.5, errors, Context(contentId, f => filter = f)); Assert.Empty(errors); }
public async Task Should_not_add_error_if_string_value_found() { var sut = new UniqueValidator(); var filter = string.Empty; await sut.ValidateAsync("hi", errors, Context(contentId, f => filter = f, ValidationMode.Default)); Assert.Empty(errors); }
public async Task Should_not_add_error_if_string_value_not_found_but_in_optimized_mode() { var sut = new UniqueValidator(); var filter = string.Empty; await sut.ValidateAsync("hi", errors, Context(Guid.NewGuid(), f => filter = f, ValidationMode.Optimized)); Assert.Empty(errors); }
public async Task Should_not_add_error_if_same_content_with_double_value_found() { var ctx = ValidationTestExtensions.CreateContext().Nested("property").Nested("iv"); var sut = new UniqueValidator(FoundDuplicates(ctx.ContentId)); await sut.ValidateAsync(12.5, ctx, ValidationTestExtensions.CreateFormatter(errors)); Assert.Empty(errors); }
public async Task Should_not_check_uniqueness_if_localized_string() { var filter = string.Empty; var sut = new UniqueValidator(FoundDuplicates(DomainId.NewGuid(), f => filter = f)); await sut.ValidateAsync(12.5, errors, updater : c => c.Nested("property").Nested("de")); Assert.Empty(errors); Assert.Empty(filter); }
public async Task Should_add_error_if_double_value_not_found() { var filter = string.Empty; var sut = new UniqueValidator(Check(DomainId.NewGuid(), f => filter = f)); await sut.ValidateAsync(12.5, errors, updater : c => c.Nested("property").Nested("iv")); errors.Should().BeEquivalentTo( new[] { "property: Another content with the same value exists." }); Assert.Equal("Data.property.iv == 12.5", filter); }
public async Task Should_add_error_if_string_value_not_found() { var sut = new UniqueValidator(); var filter = string.Empty; await sut.ValidateAsync("hi", errors, Context(Guid.NewGuid(), f => filter = f)); errors.Should().BeEquivalentTo( new[] { "property: Another content with the same value exists." }); Assert.Equal("Data.property.iv == 'hi'", filter); }
public async Task Should_add_error_if_other_content_with_string_value_found() { var filter = string.Empty; var sut = new UniqueValidator(FoundDuplicates(DomainId.NewGuid(), f => filter = f)); await sut.ValidateAsync("hi", errors, updater : c => c.Nested("property").Nested("iv")); errors.Should().BeEquivalentTo( new[] { "property.iv: Another content with the same value exists." }); Assert.Equal("Data.property.iv == 'hi'", filter); }