Inheritance: Controller
示例#1
0
        public void IndexTest()
        {
            var mockData = new FakeDbSet<ValuesTable>();
              var mock = new Mock<Entities>();

              mock.Setup(m => m.ValuesTable).Returns(mockData);
              HomeController controller = new HomeController(mock.Object);
              ActionResult result = controller.Index();
              Assert.IsNotNull(result);
        }
示例#2
0
        public void DetailsTest()
        {
            var mockData = new FakeDbSet<ValuesTable>() { new ValuesTable() { Computer = "aaa", Counter = "CPU", CounterValue = 10.23, Id = 0, Time = DateTime.Now } };
              var mock = new Mock<Entities>();

              mock.Setup(m => m.ValuesTable).Returns(mockData);
              HomeController controller = new HomeController(mock.Object);
              ViewResult result = controller.Details(0) as ViewResult;
              Assert.IsNotNull(result);
              var reading = (ValuesTable)result.ViewData.Model;
              Assert.AreEqual("aaa", reading.Computer);
              Assert.AreEqual("CPU", reading.Counter);
        }
示例#3
0
 public PartialViewResult DSDuAnHangMuc(string title, string category, int?page)
 {
     try
     {
         ViewBag.TITLE = title;
         ViewBag.CATE  = category;
         //if (category.Trim()=="du-an-nhiem-vu")
         //{
         //    category = "du-an-hang-muc-dau-tu";
         //}
         HomeController hController = new HomeController();
         var            listData    = hController.GetCacheTinBai().Where(x => x.CateKey == category).ToList();
         int            pageSize    = 15;
         int            pageNumber  = (page ?? 1);
         return(PartialView(listData.ToPagedList(pageNumber, pageSize)));
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
         return(PartialView());
     }
 }