public void CustomerValidatorTest() { var customer = new Customer() { Name = "배성혁", Company = "리얼웹", Discount = 12.5m, ZipCode = "135-010" }; var result = ValidatorTool.Validate(customer); result.IsValid.Should().Be.True(); result.Errors.Count.Should().Be(0); customer = new Customer() { Name = "", Company = "", Discount = 12.5m, ZipCode = "" }; result = ValidatorTool.Validate(customer); result.IsValid.Should().Be.False(); result.Errors.Count.Should().Be.GreaterThan(0); foreach(var failure in result.Errors) { Console.WriteLine(failure); } }
public void GetValidatorOfTest() { var customer = new Customer(); var validator = ValidatorTool.GetValidatorOf(customer); validator.Should().Not.Be.Null(); var user = new User(); validator = ValidatorTool.GetValidatorOf(user); validator.Should().Not.Be.Null(); }
public void InValidCustomerTest() { var customer = new Customer() { Name = "", Company = "", HasDiscount = true, }; var customerValidator = new CustomerValidator(); var result = customerValidator.Validate(customer); result.IsValid.Should().Be.False(); result.Errors.Count.Should().Be.GreaterThan(0); }
public void ValidCustomerTest() { var customer = new Customer() { Name = "배성혁", Company = "리얼웹", Discount = 12.5m, ZipCode = "135-010" }; var customerValidator = new CustomerValidator(); var result = customerValidator.Validate(customer); result.IsValid.Should().Be.True(); result.Errors.Count.Should().Be(0); }
public void InValidCustomerTest() { var customer = new Customer() { Name = "", Company = "", HasDiscount = true, }; var factory = new ValidatorFactory(); var customerValidator = factory.GetValidator(typeof(Customer)); var result = customerValidator.Validate(customer); result.IsValid.Should().Be.False(); result.Errors.Count.Should().Be.GreaterThan(0); result.Errors.RunEach(err => Console.WriteLine(err.ErrorMessage)); }