private NumberField AddField() { var field = new NumberField(1, "my-field", Partitioning.Invariant); sut = sut.AddOrUpdateField(field); return(field); }
public async Task Should_not_add_error_if_number_is_valid() { var sut = new NumberField(1, "my-number", Partitioning.Invariant); await sut.ValidateAsync(CreateValue(null), errors); Assert.Empty(errors); }
public async Task Should_add_errors_if_value_is_not_valid() { var sut = new NumberField(1, "my-number", Partitioning.Invariant); await sut.ValidateAsync(CreateValue("Invalid"), errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> is not a valid value." }); }
public async Task Should_add_errors_if_number_is_not_allowed() { var sut = new NumberField(1, "my-number", Partitioning.Invariant, new NumberFieldProperties { AllowedValues = ImmutableList.Create(10d) }); await sut.ValidateAsync(CreateValue(20), errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> is not an allowed value." }); }
public async Task Should_add_errors_if_number_is_greater_than_max() { var sut = new NumberField(1, "my-number", Partitioning.Invariant, new NumberFieldProperties { MaxValue = 10 }); await sut.ValidateAsync(CreateValue(20), errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> must be less than '10'." }); }
public async Task Should_add_errors_if_number_is_required() { var sut = new NumberField(1, "my-number", Partitioning.Invariant, new NumberFieldProperties { IsRequired = true }); await sut.ValidateAsync(CreateValue(null), errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> is required." }); }
public void Should_clone_object() { var sut = new NumberField(1, "my-number", Partitioning.Invariant); Assert.NotEqual(sut, sut.Enable()); }
public void Should_instantiate_field() { var sut = new NumberField(1, "my-number", Partitioning.Invariant); Assert.Equal("my-number", sut.Name); }