コード例 #1
0
        public void GetAll_GetAll3CreatedBrands_ShouldReturnTrue()
        {
            //Arrange
            BrandCollection brandCollection = new BrandCollection(new BrandTestDAL());

            Brand brand0 = new Brand()
            {
                Id     = 0,
                Name   = "TestNameGet1",
                Origin = "TestOriginGet1"
            };
            Brand brand1 = new Brand()
            {
                Id     = 1,
                Name   = "TestNameGet2",
                Origin = "TestOriginGet2"
            };
            Brand brand2 = new Brand()
            {
                Id     = 2,
                Name   = "TestNameGet3",
                Origin = "TestOriginGet3"
            };

            brandCollection.Create(brand0);
            brandCollection.Create(brand1);
            brandCollection.Create(brand2);

            List <Brand> expectedBrandList = new List <Brand>();

            expectedBrandList.Add(brand0);
            expectedBrandList.Add(brand1);
            expectedBrandList.Add(brand2);

            bool actual = true;

            //Act
            List <Brand> actualBrandList = brandCollection.GetAll();

            //Assert
            for (int i = 0; i < 2; i++)
            {
                if (expectedBrandList[i].Id != actualBrandList[i].Id &
                    expectedBrandList[i].Name != actualBrandList[i].Name &
                    expectedBrandList[i].Origin != actualBrandList[i].Origin)
                {
                    actual = false;
                }
            }

            Assert.AreEqual(true, actual);
        }