public void given_valid_object_then_Validate_succeeds() { var instance = new RootObject(); Action action = () => MessageValidator.Validate(instance); action.Should().NotThrow(); }
public void given_null_stem_then_Validate_succeeds() { var instance = new RootObject { StemObjectProperty = null }; Action action = () => MessageValidator.Validate(instance); action.Should().NotThrow(); }
public void given_root_has_invalid_property_then_Validate_throws_ValidationException() { var instance = new RootObject { Int32Property = -1, }; Action action = () => MessageValidator.Validate(instance); action.Should().Throw <ValidationException>() .Where(x => x.ValidationAttribute is RangeAttribute) .Which.ValidationResult.MemberNames.Should() .BeEquivalentTo("Int32Property"); }
public void given_stem_has_invalid_property_then_Validate_throws_ValidationException() { var instance = new RootObject { StemObjectProperty = { StringProperty = "f to the o to the o", }, }; Action action = () => MessageValidator.Validate(instance); action.Should().Throw <ValidationException>() .Where(x => x.ValidationAttribute is StringLengthAttribute) .Which.ValidationResult.MemberNames.Should() .BeEquivalentTo("StemObjectProperty.StringProperty"); }
public void given_null_argument_then_Validate_succeeds() { Action action = () => MessageValidator.Validate(instance: null); action.Should().NotThrow(); }