public void Index_Get_RetriveAllContactFromReporsitry() { //Arrange Contact contact1 = new Repositiry.Contact { Id = 100, Name = "adjen" }; Contact contact2 = new Repositiry.Contact { Id = 200, Name = "sagepay" }; InMemoryContactRepository repository = new InMemoryContactRepository(); repository.CreateNewContact(contact1); repository.CreateNewContact(contact2); HomeController controller = GetHomeController(repository); // Act var result = controller.Index() as ViewResult; var model = (IEnumerable <Contact>)result.ViewData.Model; CollectionAssert.Contains(model.ToList(), contact1); CollectionAssert.Contains(model.ToList(), contact2); }