public void VerifyCustomerPaymentOptions() { var possiblePaymentTypes = new[] { "BankDraft, CreditCard, Cash", "BankDraft, CreditCard", "BankDraft, Cash", "CreditCard, Cash", "CreditCard", "Cash", "BankDraft", }; var amounts = new[] {0M, 10M, 100M, 200M}; var customerLocations = new[] {"SD", "IA"}; CombinationApprovals.VerifyAllCombinations((allowedPaymentTypes,amount,location) => { var paymentService = new PaymentService(); var parts = allowedPaymentTypes.Split(','); paymentService.ApplicationAllowedPaymentTypes = parts.Select(x => (PaymentTypes) System.Enum.Parse(typeof(PaymentTypes), x)).ToArray(); var customer = new Customer() { HomeAddress = new Address() {State = location} }; var customerAllowedPaymentTypes = paymentService.GetAllowedPaymentTypes(customer, amount).ToArray(); return string.Join(",", customerAllowedPaymentTypes); },possiblePaymentTypes,amounts,customerLocations); }
public void Approval_FullnameIsFirstnameAndLastname() { var customer = new Customer { Firstname = "Bartx", Lastname = "Simpson" }; Approvals.Verify(customer.Fullname() + Environment.NewLine); }
public void FullnameIsFirstnameAndLastname() { var customer = new Customer { Firstname = "Bart", Lastname = "Simpson" }; Assert.AreEqual("Bart Simpson",customer.Fullname()); }
public bool AreCreditCardMerchantsSetup(Customer c) { //maybe have some system level tables //then need to check for the customer //in this example we've only configured for //customers in SD or NE state if(c.HomeAddress != null && c.HomeAddress.State == "SD") { return true; } else if(c.HomeAddress != null && c.HomeAddress.State == "NE") { return true; } return false; }
public IEnumerable<PaymentTypes> GetAllowedPaymentTypes(Customer c,decimal amount) { var systemOptions = new SystemLevelOptions(); //we'll allways allow cash yield return PaymentTypes.Cash; //only allow bank if amount less than $100 and it is in our allowed payment types if(ApplicationAllowedPaymentTypes.Contains(PaymentTypes.BankDraft)) { if(amount < 100M) { yield return PaymentTypes.BankDraft; } } if(systemOptions.AreCreditCardMerchantsSetup(c)) { if(ApplicationAllowedPaymentTypes.Contains(PaymentTypes.CreditCard)) { yield return PaymentTypes.CreditCard; } } }
public void Setup() { _customer = new Customer() { Firstname = "Bart", Lastname = "Simpson", Birthday = new DateTime(1989, 12, 17), DriversLicense = "EatMyShorts", HomeAddress = new Address() { City = "Springfield", State = "XY", Zip = "55555" }, Phone1 = "1112223333", Phone2 = "9998887777", SSN = "123456789" }; }