public void Can_ChangeQuality()
        {
            //Arrange
            QualityBasedConditionChanger qualityChanger = new QualityBasedConditionChanger();
            var NewGlass = new TestGlass()
            {
                Quality = 100
            };
            var GoodGlass = new TestGlass()
            {
                Quality = 80
            };
            var DamagedGlass = new TestGlass()
            {
                Quality = 50
            };
            var BrokenGlass = new TestGlass()
            {
                Quality = 20
            };

            //Act
            qualityChanger.ChangeCondition(NewGlass);
            qualityChanger.ChangeCondition(GoodGlass);
            qualityChanger.ChangeCondition(DamagedGlass);
            qualityChanger.ChangeCondition(BrokenGlass);

            //Assert
            Assert.AreEqual("New", NewGlass.Condition);
            Assert.AreEqual("Good", GoodGlass.Condition);
            Assert.AreEqual("Damaged", DamagedGlass.Condition);
            Assert.AreEqual("Broken", BrokenGlass.Condition);
        }
        public void Initialize()
        {
            cleanTestGlass1 = new TestGlass()
            {
                IsClean = true
            };
            cleanTestGlass2 = new TestGlass()
            {
                IsClean = true
            };
            dirtyTestGlass3 = new TestGlass()
            {
                IsClean = false
            };
            dirtyTestGlass4 = new TestGlass()
            {
                IsClean = false
            };

            cleanGlasswareCollection = new List <IGlassware>()
            {
                cleanTestGlass1, cleanTestGlass2
            };
            dirtyGlasswareCollection = new List <IGlassware>()
            {
                dirtyTestGlass3, dirtyTestGlass4, cleanTestGlass2
            };
        }
        public void Can_Check_Quality()
        {
            //Arrange
            IConditionChanger changer   = new QualityBasedConditionChanger();
            var       qualityController = new QualityControl();
            TestGlass goodQualityGlass  = new TestGlass()
            {
                Quality = 100, Condition = "New"
            };
            TestGlass brokenGlass = new TestGlass()
            {
                Quality = 15, Condition = "Broken"
            };
            List <TestGlass> listOfGlassware = new List <TestGlass>()
            {
                goodQualityGlass, brokenGlass
            };

            //Act
            qualityController.CheckQuality(goodQualityGlass);
            //Assert
            Assert.IsFalse(qualityController.QualityControlFailed);

            //Act
            qualityController.CheckQuality(brokenGlass);
            //Assert
            Assert.IsTrue(qualityController.QualityControlFailed);

            //Act
            qualityController.CheckQuality(listOfGlassware);
            //Assert
            Assert.IsTrue(qualityController.QualityControlFailed);
        }
        public void Can_Wash_All_Items()
        {
            //Arrange
            var testItem1 = new TestGlass {
                Name = "testPiece1", IsClean = false
            };
            var testItem2 = new TestGlass {
                Name = "testPiece2", IsClean = false
            };
            var testItem3 = new TestGlass {
                Name = "testPiece3", IsClean = false
            };

            var testCollection = new List <IGlassware>()
            {
                testItem1, testItem2, testItem3
            };

            //Act
            washer.Wash(testCollection);

            //Assert
            Assert.AreEqual(true, testItem1.IsClean);
            Assert.AreEqual(true, testItem2.IsClean);
            Assert.AreEqual(true, testItem3.IsClean);
        }
Beispiel #5
0
        public void Can_Change_Quality()
        {
            //Arrange
            TestGlass testGlass = new TestGlass {
                Quality = 100
            };
            RandomQualityChanger qualityChanger = new RandomQualityChanger();

            //Act
            qualityChanger.ChangeQuality(testGlass);

            //Assert
            Assert.AreNotEqual(100, testGlass.Quality);
        }
        public void Can_Wash_Item()
        {
            //Arrange
            TestGlass testGlass = new TestGlass()
            {
                IsClean = false
            };

            //Act
            washer.Wash(testGlass);

            //Assert
            Assert.AreEqual(true, testGlass.IsClean);
        }
        public void Can_CheckIfAllItemsAreClean()
        {
            //Arrange
            var testItem1 = new TestGlass {
                Name = "testPiece1", IsClean = false
            };
            var testItem2 = new TestGlass {
                Name = "testPiece2", IsClean = false
            };
            var testItem3 = new TestGlass {
                Name = "testPiece3", IsClean = false
            };
            var testItem4 = new TestGlass {
                Name = "testPiece4", IsClean = true
            };
            var testItem5 = new TestGlass {
                Name = "testPiece5", IsClean = true
            };



            var dirtyTestCollection = new List <IGlassware>()
            {
                testItem1, testItem2, testItem3
            };
            var cleanTestCollection = new List <IGlassware>()
            {
                testItem4, testItem5
            };
            var mixedTestCollection = new List <IGlassware>()
            {
                testItem1, testItem2, testItem3, testItem4, testItem5
            };



            //Act
            bool dirtyCollectionReturnsFalse = washer.CheckIfAllItemsAreClean(dirtyTestCollection);
            bool cleanCollectionReturnsTrue  = washer.CheckIfAllItemsAreClean(cleanTestCollection);
            bool mixedCollectionReturnsFalse = washer.CheckIfAllItemsAreClean(mixedTestCollection);

            //Assert
            Assert.IsTrue(cleanCollectionReturnsTrue);
            Assert.IsFalse(dirtyCollectionReturnsFalse);
            Assert.IsFalse(mixedCollectionReturnsFalse);
        }
Beispiel #8
0
        public void Can_GetListOfStorageItems()
        {
            //Arrange
            var testGlass1 = new TestGlass();
            var testGlass2 = new TestGlass();
            var testList   = new List <IGlassware>()
            {
                testGlass1, testGlass2
            };

            storage.AddItem(testGlass1);
            storage.AddItem(testGlass2);

            //Act
            var storageGlassware = storage.GetItems();

            //Assert
            Assert.AreEqual(testList[0], storageGlassware[0]);
            Assert.AreEqual(testList[1], storageGlassware[1]);
        }
        public void Can_CheckIfItemIsClean()
        {
            //Arrange
            TestGlass CleanTestGlass = new TestGlass()
            {
                IsClean = true
            };
            TestGlass DirtyTestGlass = new TestGlass()
            {
                IsClean = false
            };

            //Act
            bool isCleanGlassClean = washer.CheckIfItemIsClean(CleanTestGlass);
            bool isDirtyGlassClean = washer.CheckIfItemIsClean(DirtyTestGlass);


            //Assert
            Assert.IsTrue(isCleanGlassClean);
            Assert.IsFalse(isDirtyGlassClean);
        }
Beispiel #10
0
        public void Can_SumValueOfAllProducts()
        {
            //Arrange
            var testItem1 = new TestGlass {
                Name = "testPiece1", Price = 20M
            };
            var testItem2 = new TestGlass {
                Name = "testPiece2", Price = 10M
            };
            var testItem3 = new TestGlass {
                Name = "testPiece3", Price = 10M
            };

            storage.AddItem(testItem1);
            storage.AddItem(testItem2);
            storage.AddItem(testItem3);


            //Act
            var totalSum = storage.GetTotalPriceOfItems();

            //Assert
            Assert.AreEqual(40M, totalSum);
        }