public void EqualsTest() { HalfCircle sut1 = new LeftHalfCircle(50, 64, 32); HalfCircle sut2 = new LeftHalfCircle(50, 64, 32); HalfCircle sut3 = new LeftHalfCircle(100, 64, 32); Assert.True(sut1.Equals(sut2)); Assert.False(sut1.Equals(sut3)); }
public void TranslationTest() { //Translation is when two shapes have the same size and form but might be differently positioned. HalfCircle sut1 = new LeftHalfCircle(50, 64, 32); HalfCircle sut2 = new LeftHalfCircle(100, 64, 32); HalfCircle sut3 = new LeftHalfCircle(50, 84, 32); HalfCircle sut4 = new RightHalfCircle(100, 64, 32); Assert.True(sut1.HorizontallyTranslates(sut2), "horizontal translation between the half circles should be true."); Assert.True(sut2.HorizontallyTranslates(sut1), "horizontal translation between the half circles should be true."); Assert.False(sut3.HorizontallyTranslates(sut1), "horizontal translation between the half circles should be false."); Assert.False(sut4.HorizontallyTranslates(sut1), "horizontal translation between the half circles should be false."); }
public void SymbolOfLeftHalfCircleIntegrationTest() { Shape shape = new LeftHalfCircle(50, 96, 32); Symbol symbol1 = new Symbol("M82,64 A 32,32 0 1,0 82,128"); //absolute upper to lower Symbol symbol2 = new Symbol("M82,64 a 32,32 0 1,0 0,64"); //relative upper to lower Symbol symbol3 = new Symbol("M82,128 A 32,32 0 0,1 82,64"); //absolute lower to upper Symbol symbol4 = new Symbol("M82,128 a 32,32 0 0,1 0,-64"); //relative lower to upper Assert.True(symbol1.Contains(shape)); Assert.True(symbol2.Contains(shape)); Assert.True(symbol3.Contains(shape)); Assert.True(symbol4.Contains(shape)); }
public void ConstructorShouldSetCorrectValues() { int cx = 84; int cy = 64; int radius = 32; HalfCircle sut = new LeftHalfCircle(cx, cy, radius); Assert.Equal(cx, sut.CX); //x of half circle's center is not correct"); Assert.Equal(cy, sut.CY); //y of half circle's center is not correct"); Assert.Equal(radius, sut.Radius); //radius of half circle is not correct"); Assert.Equal(cx - radius, sut.X); //x of square of inscribed half circle is not correct"); Assert.Equal(cy - radius, sut.Y); //y of square of inscribed half circle is not correct"); Assert.Equal(radius, sut.Width); //width of square of inscribed half circle is not correct"); Assert.Equal(radius * 2, sut.Height); //height of square of inscribed half circle is not correct"); }
protected Shape CreateShape(PathCommand c) { Shape shape = null; if (c.IsMoveToCommand()) { // } else if (c.IsArcCommand()) { if (c.IsCircular()) { if (c.IsHorizontal()) { if (c.IsLower()) { shape = new LowerHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusX); } else if (c.IsUpper()) { shape = new UpperHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusX); } } else if (c.IsVertical()) { if (c.IsLeft()) { shape = new LeftHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusY); } else if (c.IsRight()) { shape = new RightHalfCircle((int)c.CenterX, (int)c.CenterY, (int)c.RadiusY); } } } } return shape; }
public void ShouldBeCorrectShapeType() { LeftHalfCircle sut = new LeftHalfCircle(0, 0, 0); Assert.Equal(ShapeType.LeftHalfCircle, sut.ShapeType); }