public void TestHeroesList() { var testHeroes = new [] { new Hero() { ID = 1, Name = "Foo", RealName = "Bar" } }; // Note the use of Moq (=mocking framework) here. Learn more at // https://github.com/Moq/moq4/wiki/Quickstart var mockRepository = new Mock <IHeroRepository>(); mockRepository.Setup(repo => repo.GetAll()).Returns(testHeroes); var controller = new HeroesController(mockRepository.Object); var result = controller.Index(); Assert.IsInstanceOfType(result, typeof(ViewResult)); CollectionAssert.AreEquivalent(testHeroes, (ICollection)((ViewResult)result).Model); }