public void ListOfGroups_Test() { // Arrange IEnumerable<Group> fakeCategories = new List<Group> { new Group { GroupName = "Test1", Description="Test1Desc"}, new Group { GroupName= "Test2", Description="Test2Desc"}, new Group { GroupName = "Test3", Description="Test3Desc"} }.AsEnumerable(); groupRepository.Setup(x => x.GetAll()).Returns(fakeCategories); GroupController controller = new GroupController(groupService, groupUserService, userService, metricService, focusService, groupgoalService, groupInvitationService, securityTokenService, groupUpdateService, groupCommentService, goalStatusService, groupRequestService, followUserService, groupCommentUserService, groupUpdateSupportService, groupUpdateUserService); // Act ViewResult result = controller.ListOfGroups() as ViewResult; // Assert Assert.IsNotNull(result, "View Result is null"); Assert.IsInstanceOf(typeof(IEnumerable<Group>), result.ViewData.Model, "Wrong View Model"); var grp = result.ViewData.Model as IEnumerable<Group>; Assert.AreEqual(3, grp.Count(), "Got wrong number of Groups"); }