public void ExpiryMonthBetweenOneAndTwelve() { var model = new PaymentRequestSource() { Cvv = "333", ExpiryMonth = 1, ExpiryYear = DateTime.Now.Year, Name = "Kamal", Number = "4111111111111111", Type = "card" }; for (int i = 0; i < 14; i++) { model.ExpiryMonth = i; var results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == (i > 0 && i <= 12 ? 0 : 1)); } }
public void ShouldHaveValidCurrency() { var model = new PaymentRequest() { Amount = 10, Currency = "GBP", Reference = "ref", Source = new PaymentRequestSource() { Cvv = "333", ExpiryMonth = 12, ExpiryYear = DateTime.Now.Year, Name = "Kamal", Number = "4111111111111111", Type = "card" } }; var results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); model.Currency = "xxx"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 1); model.Currency = "USD"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); model.Currency = "US"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count > 0); model.Currency = "USDD"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count > 0); }
public void FullModelShouldNotThrowValidationErrors() { var model = new PaymentRequest() { Amount = 10, Currency = "GBP", Reference = "ref", Source = new PaymentRequestSource() { Cvv = "333", ExpiryMonth = 12, ExpiryYear = DateTime.Now.Year, Name = "Kamal", Number = "4111111111111111", Type = "card" } }; var results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); }
public void ExpiryDateBetweenNowAndTenYears() { var model = new PaymentRequestSource() { Cvv = "333", ExpiryMonth = 12, ExpiryYear = DateTime.Now.Year, Name = "Kamal", Number = "4111111111111111", Type = "card" }; var results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); model.ExpiryYear = DateTime.Now.Year - 1; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 1); Assert.IsTrue(results[0].MemberNames.Contains("ExpiryYear")); model.ExpiryYear = DateTime.Now.Year + 5; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); model.ExpiryYear = DateTime.Now.Year + 10; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); model.ExpiryYear = DateTime.Now.Year + 11; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 1); Assert.IsTrue(results[0].MemberNames.Contains("ExpiryYear")); }
public void CVVLength() { var model = new PaymentRequestSource() { Cvv = "333", ExpiryMonth = 12, ExpiryYear = DateTime.Now.Year, Name = "Kamal", Number = "4111111111111111", Type = "card" }; var results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); model.Cvv = "33"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 1); Assert.IsTrue(results[0].MemberNames.Contains("Cvv")); model.Cvv = "3333"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 0); model.Cvv = "33333"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 1); Assert.IsTrue(results[0].MemberNames.Contains("Cvv")); }
public void CardNumberShouldHaveCorrectFormat() { var model = new PaymentRequestSource() { Cvv = "333", ExpiryMonth = 12, ExpiryYear = DateTime.Now.Year, Name = "Kamal", Number = "411111111111", Type = "card" }; var results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 1); Assert.IsTrue(results[0].MemberNames.Contains("Number")); model.Number = "A111111111111111"; results = TestModelHelper.Validate(model); Assert.IsTrue(results.Count == 1); Assert.IsTrue(results[0].MemberNames.Contains("Number")); }