public void CreateTryangleAndFindMeasure() { var rand = _rand.Next(1, 50) + _rand.NextDouble(); var rand2 = _rand.Next(1, 50) + _rand.NextDouble(); var tryangle = new Tryangle(new Point(0, 0), rand, rand2, new Perimeter()); Assert.AreEqual(rand + rand2 + tryangle.Hyppotenusa, tryangle.GetMeasure()); tryangle = new Tryangle(new Point(0, 0), rand, rand2, new Area()); Assert.AreEqual(rand * rand2 / 2, tryangle.GetMeasure()); }
public void CreateGroupAndFindMeasure() { var rand = _rand.Next(1, 50) + _rand.NextDouble(); var rand2 = _rand.Next(1, 50) + _rand.NextDouble(); var ellipse = new Ellipse(new Point(0, 0), rand, rand2, new Perimeter()); var tryangle = new Tryangle(new Point(0, 0), rand, rand2, new Perimeter()); var square = new Square(new Point(0, 0), rand, new Perimeter()); ShapeGroup <IMeasurable> sg = new ShapeGroup <IMeasurable>(new GroupMeasure(new AddOperator())); sg.Add(ellipse); sg.Add(tryangle); sg.Add(square); var groupMeasure = sg.GetMeasure(); Assert.AreEqual(ellipse.GetMeasure() + tryangle.GetMeasure() + square.GetMeasure(), groupMeasure); var anotherGroup = new ShapeGroup <IMeasurable>(new GroupMeasure(new AddOperator())); anotherGroup.Add(ellipse); anotherGroup.Add(tryangle); anotherGroup.Add(square); sg.Add(anotherGroup); Assert.AreEqual(groupMeasure + anotherGroup.GetMeasure(), sg.GetMeasure()); }