public void OrderSystem_PaymentPlan_CreateFromOrder_FirstPurchaseOrder() { Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid()); cart.OrderForms[0].Payments.Clear(); cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment()); cart.AcceptChanges(); cart.RunWorkflow("CartValidate"); cart.RunWorkflow("CartPrepare"); cart.OrderForms[0].Payments[0].Amount = cart.Total; //cart.RunWorkflow("CartCheckout"); cart.AcceptChanges(); // Create payment plan PaymentPlan plan = cart.SaveAsPaymentPlan(); // Set some payment plan values // Monthly subscription for a year plan.CycleMode = PaymentPlanCycle.Months; plan.CycleLength = 1; plan.MaxCyclesCount = 12; plan.StartDate = DateTime.UtcNow; plan.EndDate = DateTime.UtcNow.AddMonths(13); plan.LastTransactionDate = DateTime.UtcNow; // Send emails OrderHelper.SendEmail(plan, "order-paymentplan-confirm"); OrderHelper.SendEmail(plan, "order-paymentplan-notify"); // Now create first PO from the payment plan PurchaseOrder po = plan.SaveAsPurchaseOrder(); // Validate Assert.AreEqual(po.OrderForms[0].Payments.Count, 1); }
private void cleanerTest() // I think { // Create cart Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid()); getCustomerNames(); Random random = new Random((int)DateTime.Now.TimeOfDay.TotalMilliseconds); String customerFullName = _customerNames[random.Next(0, _customerNames.Length - 1)]; int space = customerFullName.IndexOf(' '); String customerFirstName = customerFullName.Substring(0, space); String customerLastName = customerFullName.Substring(space + 1); String customerHomeId = customerFullName + "\'s " + "Home"; cart.CustomerName = customerFullName; cart.OrderAddresses[0].Name = customerHomeId; cart.OrderAddresses[0].FirstName = customerFirstName; cart.OrderAddresses[0].LastName = customerLastName; #region Add items to cart // Random number of line items in an order int itemNum = random.Next(3, 10); // Add remaining items since default cart creates 3 line items for (int i = 3; i < itemNum; i++) { cart.OrderForms[0].LineItems.Add(OrderHelper.CreateLineItem()); } // Overwrite default line item info for (int i = 0; i < itemNum; i++) { int quantity = random.Next(1, 10); cart.OrderForms[0].LineItems[i].Quantity = quantity; //cart.OrderForms[0].LineItems[i].ListPrice = } cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment()); cart.RunWorkflow("CartValidate"); cart.RunWorkflow("CartPrepare"); cart.OrderForms[0].Payments[0].Amount = cart.Total; cart.RunWorkflow("CartCheckout"); #endregion // Last step cart.SaveAsPurchaseOrder(); }
public void OrderSystem_UnitTest_Payments_CreditCardSucceed() { Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid()); cart.OrderForms[0].Payments.Clear(); cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment()); cart.AcceptChanges(); cart.RunWorkflow("CartValidate"); cart.RunWorkflow("CartPrepare"); cart.OrderForms[0].Payments[0].Amount = cart.Total; // Following line throws exception: // "Authorize.NET payment gateway is not configured correctly. User is not set.." cart.RunWorkflow("CartCheckout"); cart.AcceptChanges(); PurchaseOrder po = cart.SaveAsPurchaseOrder(); po = OrderContext.Current.GetPurchaseOrder(po.CustomerId, po.OrderGroupId); // Validate Assert.AreEqual(po.OrderForms[0].Payments.Count, 1); }
public void OrderSystem_Notifications_CreditCard_CustomerEmail() { Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid()); cart.OrderForms[0].Payments.Clear(); cart.OrderForms[0].Payments.Add(OrderHelper.CreateCreditCardPayment()); cart.AcceptChanges(); cart.RunWorkflow("CartValidate"); cart.RunWorkflow("CartPrepare"); //cart.RunWorkflow("CartCheckout"); cart.AcceptChanges(); PurchaseOrder po = cart.SaveAsPurchaseOrder(); po = OrderContext.Current.GetPurchaseOrder(po.CustomerId, po.OrderGroupId); // Send emails OrderHelper.SendEmail(po, "order-purchaseorder-confirm"); OrderHelper.SendEmail(po, "order-purchaseorder-notify"); // Validate Assert.AreEqual(po.OrderForms[0].Payments.Count, 1); }
public void OrderSystem_UnitTest_Payments_CreditCard_SaveAndRetrieveSucceed() { Cart cart; Cart cartVerify; CreditCardPayment payment; CreditCardPayment paymentVerify; string cardType = "Visa"; int expMonth = 3; int expYear = DateTime.Now.AddYears(1).Year; string propertyMismatchError = "CreditCardPayment fields not saved to the database."; //A cart has to exist for a payment instance to be created cart = OrderHelper.CreateCartSimple(Guid.NewGuid()); cart.OrderForms[0].Payments.Clear(); //create cc payment to validate test account payment = (CreditCardPayment)OrderHelper.CreateCreditCardPayment(); payment.CardType = cardType; payment.ExpirationMonth = expMonth; payment.ExpirationYear = expYear; //save the cart and then retrieve the cart from the database cartVerify = SaveAndRetrieveCart(cart, payment); //confirm the payment is retrieved Assert.AreNotEqual(cartVerify.OrderForms[0].Payments.Count, 0, "Credit Card Payment not saved to the database"); //verify returned type is correct Assert.AreEqual(cartVerify.OrderForms[0].Payments[0].GetType(), typeof(CreditCardPayment), "CreditCardPayment type not saved properly."); //verify properties set and returned correctly paymentVerify = (CreditCardPayment)cartVerify.OrderForms[0].Payments[0]; Assert.AreEqual(paymentVerify.CardType, cardType, propertyMismatchError); Assert.AreEqual(paymentVerify.ExpirationMonth, expMonth, propertyMismatchError); Assert.AreEqual(paymentVerify.ExpirationYear, expYear, propertyMismatchError); }