public void RationControllerPostAddRation() { PacketDetail packetDetail = new PacketDetail(); packetDetail.PacketContent = Convert.ToString(TestContext.DataRow["PacketContent"]); packetDetail.PacketTypeId = Convert.ToString(TestContext.DataRow["PacketTypeId"]); if (Convert.ToString(TestContext.DataRow["PacketTypeId"]) == "1") { packetDetail.Calories = Convert.ToInt32(TestContext.DataRow["Calories"]); } if (Convert.ToString(TestContext.DataRow["PacketTypeId"]) == "1") { packetDetail.Datestart = Convert.ToString(TestContext.DataRow["ExpiryDate"]); //packetDetail.ExpiryDate = Convert.ToDateTime(packetDetail.Datestart); } if (Convert.ToString(TestContext.DataRow["PacketTypeId"]) == "2") { packetDetail.LitersQty = Convert.ToInt32(TestContext.DataRow["QuantityOfLtr"]); } DataContext dataContext = new DataContext(); PacketDetailRepository packetDetailRepository = new PacketDetailRepository(dataContext); PacketTypeRepository packetTypeRepository = new PacketTypeRepository(dataContext); ErrorLogsRepository errorLogsRepository = new ErrorLogsRepository(dataContext); RationController rationController = new RationController(packetDetailRepository, packetTypeRepository, errorLogsRepository); ViewResult result = rationController.AddRation(packetDetail) as ViewResult; // Assert Assert.IsNull(result); }
public void RationControllerGetAddRation() { DataContext dataContext = new DataContext(); PacketDetailRepository packetDetailRepository = new PacketDetailRepository(dataContext); PacketTypeRepository packetTypeRepository = new PacketTypeRepository(dataContext); ErrorLogsRepository errorLogsRepository = new ErrorLogsRepository(dataContext); RationController rationController = new RationController(packetDetailRepository, packetTypeRepository, errorLogsRepository); ViewResult result = rationController.AddRation() as ViewResult; // Assert Assert.IsNotNull(result); }