public void TestCompoundShapeMath() { // arrange // manually calc sum of perimeters - line + circle + line double expectedPerimeterSum = 1 + 18.8495559215387594; // manually calc sum of areas - line + circle + line double expectedAreaSum = 0 + 28.274333882308139146; _compoundShape.Add(_line); _compoundShape.Add(_circle); // act double actualPerimeterSum = _compoundShape.GetPerimeter(); double actualAreaSum = _compoundShape.GetArea(); // assert Assert.AreEqual(expectedPerimeterSum, actualPerimeterSum); Assert.AreEqual(expectedAreaSum, actualAreaSum); }
public void TestCompoundShapeMock() { // allocate double expectedAreaSum = 8; var mockShape1 = new Mock <IShapeComposition>(); var mockShape2 = new Mock <IShapeComposition>(); mockShape1.Setup(shape => shape.GetArea()).Returns(mockValue1); mockShape2.Setup(shape => shape.GetArea()).Returns(mockValue2); // act _compoundShape.Add(mockShape1.Object); _compoundShape.Add(mockShape2.Object); double actualAreaSum = _compoundShape.GetArea(); // assert Assert.AreEqual(expectedAreaSum, actualAreaSum); }