public void AddNewPaymentType_Should() { // Variable initializations _paymentType1 = new PaymentType(); _testCustomer = new Customer(); // Add a test customer to get the returned ID int custId = _custManager.AddCustomer(_testCustomer); // Adds properties to the _paymentType instance _paymentType1.Type = "Mastercard"; _paymentType1.AccountNumber = 12345678910; // Adds the _paymentType to the _paymentList in the paymentTypeManager, passes in a customerId int paymentId = _paymentTypeManager.AddNewPaymentType(_paymentType1, custId); // Asserts the properties exist PaymentType payment = _paymentTypeManager.GetSinglePaymentType(paymentId); Assert.Equal(payment.Id, paymentId); Assert.Equal(payment.CustomerId, custId); Assert.Equal(payment.Type, "Mastercard"); Assert.Equal(payment.AccountNumber, 12345678910); }
public void CloseOrder() { // add customer to DB and get id int CustomerId = _customerManager.AddCustomer(_customer); // add the customerId to _testOrder _testOrder.CustomerId = CustomerId; // add the customerId to _testProduct _testProduct.CustomerId = CustomerId; // Variable initialization for Payment Type _paymentType1 = new PaymentType(); // Adds properties to the _paymentType instance _paymentType1.Type = "Mastercard"; _paymentType1.AccountNumber = 12345678910; // add a test order int orderId = _orderManager.AddOrder(_testOrder); // add a test product int productId = _productManager.AddProduct(_testProduct); // Adds the _paymentType to the _paymentList in the paymentTypeManager, passes in a customerId int paymentId = _paymentTypeManager.AddNewPaymentType(_paymentType1, CustomerId); // get the user's unpaid order Order customerOrder = _orderManager.GetUnpaidOrder(CustomerId); // Close the order by adding the payment type selected _orderManager.CloseOrder(customerOrder.Id, paymentId); // retrieve the order and Assert that the updated values match Order retrievedOrder = _orderManager.GetOrderById(orderId); // Get the payment type info used on the order // since PaymentTypeId is currently a nullable int type, convert it to an int to use it to retrieve the payment Type details int retrievedPaymentTypeId = retrievedOrder.PaymentTypeId ?? default(int); PaymentType retrievedPaymentType = _paymentTypeManager.GetSinglePaymentType(retrievedPaymentTypeId); // Assert that the payment type matches what we used to close the order Assert.Equal("Mastercard", retrievedPaymentType.Type); Assert.Equal(12345678910, retrievedPaymentType.AccountNumber); }