Пример #1
0
        public void Square3x3Test()
        {
            var square = new LiskovSubstitutionPrinciple.Square {
                Height = 3, Width = 3
            };
            var result = LiskovSubstitutionPrinciple.AreaCalculator.CalculateArea(square);

            Assert.AreEqual(result, 9);
        }
Пример #2
0
        // Lsikov substituition Principle Example
        public static void LSP()
        {
            LiskovSubstitutionPrinciple.Rectangle rc = new LiskovSubstitutionPrinciple.Rectangle(2, 3);

            WriteLine($"{rc} has area {LiskovSubstitutionPrinciple.Area(rc)}");

            LiskovSubstitutionPrinciple.Square sq = new LiskovSubstitutionPrinciple.Square();
            sq.Width = 4;
            WriteLine($"{sq} has area {LiskovSubstitutionPrinciple.Area(sq)}");

            //Cause error if setters aren't override
            LiskovSubstitutionPrinciple.Rectangle sq2 = new LiskovSubstitutionPrinciple.Square();
            sq.Width = 4;
            WriteLine($"{sq2} has area {LiskovSubstitutionPrinciple.Area(sq2)}");
        }