public void POCO_2b_Test() { //// Arrange HomeController controller = new HomeController(new TestRepository()); // TestRepsitory is created in current test project // Act ContentResult actual = controller.POCO_2b() as ContentResult; string jsonStr = actual.Content; JavaScriptSerializer jss = new JavaScriptSerializer(); List<UserHits2bVM> resultList = jss.Deserialize<List<UserHits2bVM>>(jsonStr); //// Assert /// we could add more and test like that Assert.AreEqual(3, resultList.Count()); // check total row in json result Assert.AreEqual("N/a", resultList[2].LastDate); }
public void POCO_2d_Test() { //// Arrange HomeController controller = new HomeController(new TestRepository()); // Act ContentResult actual = controller.POCO_2d() as ContentResult; string jsonStr = actual.Content; JavaScriptSerializer jss = new JavaScriptSerializer(); List<UserHits2dVM> resultList = jss.Deserialize<List<UserHits2dVM>>(jsonStr); //// Assert Assert.AreEqual(3, resultList.Count()); Assert.AreEqual(3, resultList[0].TotalHitsCount); }