public void Index_GetAllBlogEntriesCalled() { //arrange var mockedRepository = MockRepository.GenerateMock<IBlogRepository>(); var blogController = new BlogController(mockedRepository); //act blogController.Index(); //assert mockedRepository.AssertWasCalled(blogRepository => blogRepository.GetAllBlogEntries()); }
public void Index_OneBlogEntryInRepository_BlogEntryReturnedInViewResult() { //arrange var stubbedRepository = MockRepository.GenerateStub<IBlogRepository>(); var blogEntry = new BlogEntry(); stubbedRepository.Stub(repository => repository.GetAllBlogEntries()).Return(new List<BlogEntry> {blogEntry}); var blogController = new BlogController(stubbedRepository); //act ViewResult viewResult = blogController.Index(); var blogEntries = viewResult.ViewData.Model as List<BlogEntry>; //assert Assert.AreEqual(1, blogEntries.Count); }