public void Square3x3Test() { var square = new LiskovSubstitutionPrinciple.Square { Height = 3, Width = 3 }; var result = LiskovSubstitutionPrinciple.AreaCalculator.CalculateArea(square); Assert.AreEqual(result, 9); }
// 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)}"); }