Пример #1
0
        public void AreaCalculatorWithoutDefaultsTest()
        {
            var areaCalculator = new AreaCalculator(false);

            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3));
            areaCalculator.AddShapeSidesCountConformity(1, typeof(Circle));
            Assert.AreEqual(Math.Round(areaCalculator.Calculate(3), 2), 28.27d);

            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3, 4, 5));
            areaCalculator.AddShapeSidesCountConformity(3, typeof(Triangle));
            Assert.AreEqual(Math.Round(areaCalculator.Calculate(3, 4, 5), 2), 6);

            areaCalculator.RemoveShapeSidesCountConformity(1);
            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3));
            areaCalculator.RemoveShapeSidesCountConformity(3);
            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3, 4, 5));
        }