public void OrderSystem_UnitTest_Payments_CashCard_SaveAndRetrieveSucceed() { Cart cart; Cart cartVerify; CashCardPayment payment; CashCardPayment paymentVerify; string cashCardNumber = "111"; string securityCode = "2323"; string propertyMismatchError = "CashCardPayment 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 cash card payment payment = (CashCardPayment)OrderHelper.CreateCashCardPayment(); payment.CashCardNumber = cashCardNumber; payment.CashCardSecurityCode = securityCode; //save the cart and then retrieve the cart from the database cartVerify = SaveAndRetrieveCart(cart, payment); //confirm the payment is retrieved correctly Assert.AreNotEqual(cartVerify.OrderForms[0].Payments.Count, 0, "Cash Card Payment not saved to the database"); //confirm the payment is of the right type Assert.AreEqual(cartVerify.OrderForms[0].Payments[0].GetType(), typeof(CashCardPayment), "CashCardPayment type not saved properly."); //confirm payment properties paymentVerify = (CashCardPayment)cartVerify.OrderForms[0].Payments[0]; Assert.AreEqual(paymentVerify.CashCardNumber, cashCardNumber, propertyMismatchError); Assert.AreEqual(paymentVerify.CashCardSecurityCode, securityCode, propertyMismatchError); }
public void OrderSystem_UnitTest_Payments_CashCardSucceed() { Cart cart = OrderHelper.CreateCartSimple(Guid.NewGuid()); cart.OrderForms[0].Payments.Clear(); cart.OrderForms[0].Payments.Add(OrderHelper.CreateCashCardPayment()); cart.AcceptChanges(); cart.RunWorkflow("CartValidate"); cart.RunWorkflow("CartPrepare"); cart.OrderForms[0].Payments[0].Amount = cart.Total; 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); }