public void ShouldRenderIndexViewCorrectly() { Mock <IGenericService <Goal> > goalServiceMock = new Mock <IGenericService <Goal> >(); Goal goal = new Goal() { Id = 100, Bloom = "Understand", Description = @"Je begrijpt de basismechanismen voor access control, zodanig dat je in eigen woorden kunt uitleggen wat de betekenis is in de context van software security. " }; goalServiceMock.Setup(m => m.FindAll(It.IsAny <string[]>(), It.IsAny <int>(), It.IsAny <int>())).Returns(new List <Goal>() { goal, new Goal() { Id = 101 }, new Goal() { Id = 102 }, }); GoalController controller = new GoalController(goalServiceMock.Object); List <Goal> model = (controller.Index() as ViewResult)?.ViewData.Model as List <Goal>; Assert.Equal(3, model.Count); Assert.Equal(100, model[0].Id); Assert.Equal(101, model[1].Id); Assert.Equal("Understand", model[0].Bloom); }
public void Test_Index_Returns_Goals() { var result = controller.Index(null); var model = ((ViewResult)result).Model as PagedList <Goal>; Assert.AreEqual(2, model.Count); }
public async Task Index_Model_Should_Have_3_Goals() { var expectedCount = 3; var result = await goalController.Index(); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <ToDoGoal> >( viewResult.ViewData.Model); var actualCount = model.Count(); Assert.Equal(expectedCount, actualCount); }