コード例 #1
0
        public void TestProperties_PropertyWithName_HasNoError()
        {
            var property  = new Properties("asdf");
            var testClass = new TestClass(new[] { property });

            var validator = new TestClassValidator();

            validator.ShouldNotHaveValidationErrorFor(x => x.TestProperties, testClass);
        }
コード例 #2
0
        public void TestProperties_PropertyWithNullName_HasCustomError()
        {
            var property  = new Properties(null);
            var testClass = new TestClass(new[] { property });

            var validator = new TestClassValidator();

            var validatorResult = validator.TestValidate(testClass);

            validatorResult.ShouldHaveValidationErrorFor("TestProperties[0].Name").WithErrorMessage($"TestProperty {property.Id} name can't be null or empty");
        }