GetErrors() публичный Метод

public GetErrors ( string propertyName ) : IEnumerable
propertyName string
Результат IEnumerable
        public void GetValidationResultFor_EmptyString_GetsErrorsForEntireObject()
        {
            // Arrange
            var vm = new MockViewModel();

            // Act
            vm.StringProperty = null;

            // Assert
            Assert.False(string.IsNullOrEmpty(vm.GetErrors("").Cast<string>().FirstOrDefault()));
        }
        public void RangeProperties_ChangeFromInvalidToValid_ValidationErrorsDisappear()
        {
            // Arrange
            var vm = new MockViewModel();

            // Act
            vm.RangeStart = 10;
            vm.RangeEnd = 1;

            // Assert
            Assert.False(string.IsNullOrEmpty(vm.GetErrors("RangeStart").Cast<string>().FirstOrDefault()));
            Assert.False(string.IsNullOrEmpty(vm.GetErrors("RangeEnd").Cast<string>().FirstOrDefault()));

            // Act
            vm.RangeEnd = 11;

            // Assert
            Assert.True(string.IsNullOrEmpty(vm.GetErrors("RangeStart").Cast<string>().FirstOrDefault()));
            Assert.True(string.IsNullOrEmpty(vm.GetErrors("RangeEnd").Cast<string>().FirstOrDefault()));
        }
        public void SuppressValidation_SetInvalidValue_ThereAreNoErrors()
        {
            // Arrange
            var vm = new MockViewModel();

            // Act
            using (vm.Validation.SuppressValidation())
            {
                vm.RangeStart = 10;
                vm.RangeEnd = 1;
            }

            // Verify
            Assert.True(string.IsNullOrEmpty(vm.GetErrors("RangeStart").Cast<string>().FirstOrDefault()));
            Assert.True(string.IsNullOrEmpty(vm.GetErrors("RangeEnd").Cast<string>().FirstOrDefault()));
        }
        public void StringProperty_ValidValue_DoesNotHaveValidationError()
        {
            // Arrange
            var vm = new MockViewModel();

            // Act
            vm.StringProperty = "Not empty string";

            // Assert
            Assert.False(vm.GetErrors("StringProperty").Cast<string>().Any());
        }
        public void StringProperty_InvalidValue_HasValidationError()
        {
            // Arrange
            var vm = new MockViewModel();

            // Act
            vm.StringProperty = null;

            // Assert

            Assert.True(vm.GetErrors("StringProperty").Cast<string>().Any());
        }
        public void RangeProperties_ValidRange_NonOfThePropertiesHaveValidationError()
        {
            // Arrange
            var vm = new MockViewModel();

            // Act
            vm.RangeStart = 1;
            vm.RangeEnd = 10;

            // Assert
            Assert.True(string.IsNullOrEmpty(vm.GetErrors("RangeStart").Cast<string>().FirstOrDefault()));
            Assert.True(string.IsNullOrEmpty(vm.GetErrors("RangeEnd").Cast<string>().FirstOrDefault()));
        }