示例#1
0
        public void IndexAdmin_OnRequest_ReturnsCorrectView()
        {
            FakeNewsRepository  fakeNewsRepository = new FakeNewsRepository();
            NewsAdminController controller         = CreateNewsAdminController(fakeNewsRepository);
            SearchViewModel     viewModel          = new SearchViewModel();

            ViewResult result = controller.IndexAdmin(viewModel);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ViewName == "IndexAdmin");
        }
示例#2
0
        public void IndexAdmin_OnRequest_ReturnAllNewsForUser()
        {
            FakeNewsRepository  fakeNewsRepository = new FakeNewsRepository();
            NewsAdminController controller         = CreateNewsAdminController(fakeNewsRepository);
            SearchViewModel     viewModel          = new SearchViewModel();

            ViewResult         result         = controller.IndexAdmin(viewModel);
            List <NewsArticle> articlesByUser = ((IEnumerable <NewsArticle>)result.Model).ToList();

            List <int> expectedArticlesForUser = new List <int> {
                0, 1, 2
            };

            Assert.IsTrue(TestHelper.AreDataAsExpected(articlesByUser,
                                                       fakeNewsRepository.News,
                                                       expectedArticlesForUser,
                                                       TestHelper.NewsArticlesAreSame));
        }