Exemplo n.º 1
0
        public void ReturnCorrectModelType_WhenGetToIndex()
        {
            //Arrange
            var brandsServiceMock = new Mock <IBrandsService>();
            var brands            = DataHelper.GetBrands();

            brandsServiceMock.Setup(s => s.GetAll()).Returns(brands);

            var brandsController = new AllBrandsController(brandsServiceMock.Object);

            //Act & Assert
            brandsController.WithCallTo(c => c.Index()).ShouldRenderView("Index").WithModel <List <BrandViewModel> >();
        }
Exemplo n.º 2
0
        public void RunDefaultView_WhenGetToIndex()
        {
            // Arrange
            var brandsServiceMock = new Mock <IBrandsService>();
            var brands            = DataHelper.GetBrands();

            brandsServiceMock.Setup(x => x.GetAll())
            .Returns(brands);

            var controller = new AllBrandsController(brandsServiceMock.Object);

            // Act & Assert
            controller.WithCallTo(c => c.Index())
            .ShouldRenderDefaultView();
        }
Exemplo n.º 3
0
        public void ReturnCorrectResultModel_WhenGetToIndex()
        {
            //Arrange
            var brandsServiceMock = new Mock <IBrandsService>();
            var brands            = DataHelper.GetBrands();

            brandsServiceMock.Setup(s => s.GetAll()).Returns(brands);

            var brandsController = new AllBrandsController(brandsServiceMock.Object);
            var expectedResult   = brands.ProjectTo <BrandViewModel>().ToList();

            //Act & Assert
            brandsController.WithCallTo(c => c.Index()).ShouldRenderView("Index")
            .WithModel <IList <BrandViewModel> >(x =>
            {
                Assert.AreEqual(x.FirstOrDefault().Id, expectedResult.FirstOrDefault().Id);
                Assert.AreEqual(x.FirstOrDefault().Name, expectedResult.FirstOrDefault().Name);
                Assert.AreEqual(x.FirstOrDefault().WebSite, expectedResult.FirstOrDefault().WebSite);
            });
        }