Пример #1
0
        public void CRUDController_Get_All()
        {
            //Arrange
            _moqDataBase.Setup(x => x.Lots.GetAll()).Returns(ListLot);
            // Act
            var result = ((controller.Index() as ViewResult).Model) as IEnumerable <LotViewModel>;

            //Assert
            Assert.AreEqual(result.Count(), 3);
            Assert.AreEqual("Audi", result.ToList()[0].LotName);
            Assert.AreEqual("WV", result.ToList()[1].LotName);
            Assert.AreEqual("BMW", result.ToList()[2].LotName);
        }
Пример #2
0
        private void CRUD_Index_Returns_List_Of_Entries()
        {
            A.CallTo(() => fakeBlogService.SelectAll()).Returns(listBlogs);

            var viewResult = testController.Index() as ViewResult;
            var fakePosts  = viewResult.ViewData.Model as List <BlogPost>;

            Assert.NotNull(viewResult);
            Assert.Equal(1, fakePosts[0].Id);
            Assert.Equal("Content1", fakePosts[0].Content);
            Assert.Equal("Title1", fakePosts[0].Title);
            Assert.Equal(4, fakePosts.Count);
        }
        public void Index_ActionExecutes_ReturnsViewForIndex()
        {
            var result = _controller.Index();

            Assert.IsType <ViewResult>(result);
        }