public void GetShapeAtIndex_IndexOutOfRange_ThrowsOutOfRangeException() { // Arrange var groupShape = new GroupShape(); // Act // Assert Assert.Throws <ArgumentOutOfRangeException>(() => groupShape.GetShapeAtIndex(0)); }
public void GetShapeAtIndex_ShapeHasInsertedBefore_GetInsertedShape() { // Arrange var groupShape = new GroupShape(); groupShape.InsertShape(_shapeMock.Object, 0); // Act IShape result = groupShape.GetShapeAtIndex(0); // Assert Assert.Same(_shapeMock.Object, result); }
public void GetShapeAtIndex_GroupShapeHasInserted_GetInsertedGroupShape() { // Arrange var groupShape = new GroupShape(); groupShape.InsertShape(_groupShapeMock.Object, 0); // Act var result = groupShape.GetShapeAtIndex(0) as IGroupShape; // Assert Assert.Same(_groupShapeMock.Object, result); }
public void SetFrame_GroupShapeHasTwoChilds_ChildsFrameChangedCorrectly() { // Arrange var groupShape = new GroupShape(); var rectangle = new Rectangle(new Rect(left: 0, top: 1, width: 2, height: 1)); var ellipse = new Rectangle(new Rect(left: 1, top: 2, width: 1.5f, height: 1)); groupShape.InsertShape(rectangle, 0); groupShape.InsertShape(ellipse, 1); var expectedRectangleFrame = new Rect(0, 0.5f, 0.8f, 0.5f); var expectedEllipseFrame = new Rect(0.4f, 1f, 0.6f, 0.5f); // Act groupShape.SetFrame(new Rect(0, 1, 1, 1)); Rect?rectangleFrame = groupShape.GetShapeAtIndex(0).GetFrame(); Rect?ellipseFrame = groupShape.GetShapeAtIndex(1).GetFrame(); // Assert Assert.True(rectangleFrame.HasValue && ellipseFrame.HasValue); Assert.Equal(expectedRectangleFrame, rectangleFrame); Assert.Equal(expectedEllipseFrame, ellipseFrame); }
public void GetFillStyle_ChildsWithDifferentColors_FillStyleWithoutColor() { // Arrange var fillStyle = new BaseStyle(Color.Black); GroupShape groupShape = GetGroupShape(3, lineStyle: null, fillStyle); IShape shape = groupShape.GetShapeAtIndex(0); shape.FillStyle.Color = Color.Blue; // Act IStyle result = groupShape.FillStyle; // Assert var a = result.Color; Assert.Equal(Color.Empty, result.Color); }
public void SetFrame_GroupShapeHasChild_ChangeChildFrameCorrectly() { // Arrange var groupShape = new GroupShape(); var rectangle = new Rectangle(new Rect(left: 0, top: 1, width: 2, height: 1)); groupShape.InsertShape(rectangle, 0); var expectedChildFrame = new Rect(3, 3, 3, 3); // Act groupShape.SetFrame(new Rect(3, 3, 3, 3)); Rect?result = groupShape.GetShapeAtIndex(0).GetFrame(); // Assert Assert.True(result.HasValue); Assert.Equal(expectedChildFrame, result); }
public void GetLineStyle_ChangeStyleColor_AllChildsUpdateColorToThisOne() { // Arrange var lineStyle = new LineStyle(Color.Black, thickness: 1); GroupShape groupShape = GetGroupShape(3, lineStyle); groupShape.InsertShape(GetGroupShape(3, lineStyle), 0); // Act ILineStyle result = groupShape.LineStyle; result.Color = Color.Red; // Assert for (int i = 0; i < groupShape.ShapesCount; i++) { IShape shape = groupShape.GetShapeAtIndex(i); Assert.Equal(Color.Red, shape.LineStyle.Color); } }
public IShape GetShapeAtIndex(int index) { return(_data.GetShapeAtIndex(index)); }