public void Place_Order_Test(string orderId, string dateTime, string reservationDateTime, string noSeats, bool accepted, bool shouldValidate) { Mock itemMock = new Mock <Item>(); List <Item> itemList = new List <Item> { new Mock <Item>("1000000", "Chicken Curry Soup", "Spicy curry soup with chicken breast and vegetables", "1000000").Object }; var sut = new Order { OrderId = orderId, DateTime = dateTime, ReservationDateTime = reservationDateTime, ItemsList = itemList, NoSeats = noSeats, Accepted = accepted }; var context = new ValidationContext(sut, null, null); var result = new List <ValidationResult>(); var isModelStateValid = Validator.TryValidateObject(sut, context, result, true); Assert.IsTrue(shouldValidate == isModelStateValid); }
private int CreateNewOrder(int resId, int noSeats, DateTime date) { OrderCtrl orderCtrl = new OrderCtrl(); DateTime now = DateTime.Now; string nowDate = now.Year + "-" + now.Month + "-" + now.Day + " " + now.Hour + ":" + now.Minute + ":" + now.Second + "." + now.Millisecond; string dateTime = date.Year + "-" + date.Month + "-" + date.Day + " " + date.Hour + ":" + date.Minute + ":" + date.Second + "." + date.Millisecond; var order = new ModelLibrary.Order { RestaurantId = Convert.ToString(resId), DateTime = Convert.ToString(now), ReservationDateTime = dateTime, //DateTime = nowDate, //ReservationDateTime = dateTime, NoSeats = Convert.ToString(noSeats), Accepted = false }; return(orderCtrl.AddOrder(order)); }