Example #1
0
        public static void TXTErrorLog(Exception ex, string Msg)
        {
            try
            {
                string strLogFilePath = image_Root + "logs.txt";

                if (!File.Exists(strLogFilePath))
                {
                    File.Create(strLogFilePath).Close();
                }

                using (StreamWriter w = File.AppendText(strLogFilePath))
                {
                    w.WriteLine("\r\nLog: ");
                    w.WriteLine("{0}", DateTime.Now.ToString(CultureInfo.InvariantCulture));
                    string err = "Error Message:" + ex;
                    w.WriteLine(err);
                    w.WriteLine("Message = " + Msg);
                    w.Flush();
                    w.Close();
                }
            }
            catch (Exception exc)
            {
                ErrorLogsRepository obj = new ErrorLogsRepository(new dbContext());
                obj.logError(exc);
            }
            finally { }
        }
        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 StartScheduleTestListMethod()
        {
            DataContext            dataContext            = new DataContext();
            PacketDetailRepository packetDetailRepository = new PacketDetailRepository(dataContext);
            PacketTypeRepository   packetTypeRepository   = new PacketTypeRepository(dataContext);
            ErrorLogsRepository    errorLogsRepository    = new ErrorLogsRepository(dataContext);


            string startScheduleDate = Convert.ToString(TestContext.DataRow["StartDate"]);

            RationScheduleViewModelNew rationScheduleViewModelNew = new RationScheduleViewModelNew();

            rationScheduleViewModelNew.statedate = startScheduleDate;
            RationController rationController = new RationController(packetDetailRepository, packetTypeRepository, errorLogsRepository);

            // Act
            ViewResult result = rationController.Schduled(rationScheduleViewModelNew) as ViewResult;

            // Assert
            if (result != null)
            {
                Assert.IsNotNull(result.Model);
            }
            else

            {
                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);
        }
        public void RationControllerDeleteRation()
        {
            PacketDetail packetDetail = new PacketDetail();

            packetDetail.Id = Convert.ToInt32(TestContext.DataRow["PacketId"]);;
            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);
            JsonResult       result           = rationController.DeleteRation(packetDetail) as JsonResult;

            // Assert
            Assert.IsNotNull(result);
        }
        public void RationControllerPostSchudle()
        {
            //RationScheduleViewModel rationScheduleViewModel =new RationScheduleViewModel();
            RationScheduleViewModelNew rationScheduleViewModel = new RationScheduleViewModelNew();

            rationScheduleViewModel.StartDate = DateTime.Now;
            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.Schduled(rationScheduleViewModel) as ViewResult;

            // Assert
            if (result != null)
            {
                Assert.IsNotNull(result);
            }
            else
            {
                Assert.IsNull(result);
            }
        }