public void Validator_ThrowArgumentNullException_WithNull()
        {
            // Arrange
            DataAnnotationsSampleModel model = null;
            var validationResults            = new List <ValidationResult>();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() =>
            {
                DataAnnotationsValidator.Validate(model, validationResults);
            });
        }
        public void Validator_ReturnTrue_WithExpectedParameters()
        {
            // Arrange
            DataAnnotationsSampleModel model = new DataAnnotationsSampleModel
            {
                Int32Value  = 101,
                StringValue = "测试"
            };
            var validationResults = new List <ValidationResult>();

            // Act
            var isValid = DataAnnotationsValidator.Validate(model, validationResults);

            // Assert
            Assert.True(isValid);
            Assert.True(validationResults?.Count == 0);
        }
        public void Validator_ReturnFalse_WithExpectedParameters(string stringVal, string errorMessage)
        {
            // Arrange
            DataAnnotationsSampleModel model = new DataAnnotationsSampleModel
            {
                Int32Value  = 101,
                StringValue = stringVal
            };
            var validationResults = new List <ValidationResult>();

            // Act
            var isValid = DataAnnotationsValidator.Validate(model, validationResults);

            // Assert
            Assert.False(isValid);
            Assert.True(validationResults?.Count == 1);
            Assert.True(validationResults[0].ErrorMessage.Equals(errorMessage));
        }