public void Convert_To_Database_Test() { //Setup var oli = new List <OrderLineItem>(); var ordCtrl = new OrderCtrl(); var ordDb = new Order(); var order = new Order { OrderId = "1000002", CustomerId = "1000000", RestaurantId = "1000000", DateTime = "2018-11-08 12:22:33", ReservationDateTime = "2018-11-08 18:00:00", ItemsList = oli, NoSeats = "2", Payment = "200.00", Accepted = false }; var dt = new DateTime(2018, 11, 08, 12, 22, 33); var resDt = new DateTime(2018, 11, 08, 18, 00, 00); var dbOrder = new DatabaseAccessLibrary.Order { id = 1000002, restaurantId = 1000000, dateTime = dt, reservation = resDt, noSeats = 2 }; //Act var resOrder = ordCtrl.ConvertOrder(order); //Assert Assert.IsTrue(resOrder.id == dbOrder.id && resOrder.restaurantId == dbOrder.restaurantId && resOrder.dateTime == dbOrder.dateTime && resOrder.reservation == dbOrder.reservation && resOrder.noSeats == dbOrder.noSeats); }
public void Add_Order_To_Database_Test() { //Setup var ordCtrl = new OrderCtrl(); var ordDb = new OrderDb(); var dt = new DateTime(2018, 11, 08, 12, 22, 33); var resDt = new DateTime(2018, 11, 08, 18, 00, 00); var oli = new List <OrderLineItem>(); var item = new ModelLibrary.Item(); item.Id = 1000000; oli.Add(new OrderLineItem(item, 2)); var order = new Order { OrderId = (ordCtrl.GetLastOrderIdentity() + 1).ToString(), CustomerId = "1000000", RestaurantId = "1000000", DateTime = "2018-11-08 12:22:33", ReservationDateTime = "2018-11-08 18:00:00", ItemsList = oli, NoSeats = "2", Payment = "200.00", Accepted = false }; //Act var oliList = ordCtrl.ConvertOrderLineItemsToDb(order); var dbOrder = ordCtrl.ConvertOrder(order); for (var i = 0; i < dbOrder.OrderLineItems.Count - 1; i++) { dbOrder.OrderLineItems.Add(oliList[i]); } ordDb.AddOrder(dbOrder); //Assert Assert.IsTrue(ordCtrl.GetLastOrderIdentity() == Convert.ToInt32(order.OrderId)); }