Esempio n. 1
0
        public void List_Contain_Brands()
        {
            //---Arrange---
            Mock <IRepository> mock = new Mock <IRepository>();

            mock.Setup(b => b.Brands).Returns(new Brands[]
            {
                new Brands {
                    BrandId = 1, BrandName = "B1"
                },
                new Brands {
                    BrandId = 2, BrandName = "B2"
                },
                new Brands {
                    BrandId = 3, BrandName = "B3"
                },
            });
            BrandsController controller = new BrandsController(mock.Object);

            //---Act---
            var result = ((ViewResult)controller.List()).ViewData.Model as Brands[];

            //---Assert---
            Assert.AreEqual(3, result.Length);
            Assert.AreEqual(1, result[0].BrandId);
            Assert.AreEqual(2, result[1].BrandId);
            Assert.AreEqual(3, result[2].BrandId);
        }