Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Rendering2D.Shapes.Tests FilledRectTests
Namespace: DeltaEngine.Rendering2D.Shapes.Tests
Assembly: DeltaEngine.Rendering2D.Shapes.Tests (in DeltaEngine.Rendering2D.Shapes.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The FilledRectTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
FilledRectTests | Initializes a new instance of the FilledRectTests class |
Methods
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, ApproveFirstFrameScreenshot] public void RenderRect() { new FilledRect(new Rectangle(0.3f, 0.3f, 0.4f, 0.4f), Color.Blue); }
[Test] public void RenderManyRects() { var random = Core.Randomizer.Current; for (int num = 0; num < 20; num++) new FilledRect(new Rectangle(random.Get(0.0f, 0.8f), random.Get(0.2f, 0.8f), 0.2f, 0.2f), Color.GetRandomColor()); }
[Test, ApproveFirstFrameScreenshot] public void CheckCollisionOnAllSidesWithRotatedRectangles() { var rect = new FilledRect(new Rectangle(0.4f, 0.4f, 0.2f, 0.2f), Color.White); var top = new FilledRect(new Rectangle(0.4f, 0.2f, 0.2f, 0.2f), Color.Yellow) { Rotation = 45 }; var left = new FilledRect(new Rectangle(0.2f, 0.4f, 0.2f, 0.2f), Color.Blue) { Rotation = 135 }; var bottom = new FilledRect(new Rectangle(0.4f, 0.6f, 0.2f, 0.2f), Color.Green) { Rotation = 225 }; var right = new FilledRect(new Rectangle(0.6f, 0.4f, 0.2f, 0.2f), Color.Red) { Rotation = 315 }; Assert.IsTrue(rect.DrawArea.IsColliding(0, top.DrawArea, top.Rotation)); Assert.IsTrue(rect.DrawArea.IsColliding(0, left.DrawArea, left.Rotation)); Assert.IsTrue(rect.DrawArea.IsColliding(0, bottom.DrawArea, bottom.Rotation)); Assert.IsTrue(rect.DrawArea.IsColliding(0, right.DrawArea, right.Rotation)); }
[Test] public void ControlRectanglesWithMouseAndWhenTheyCollideTheyChangeColor() { var r1 = new FilledRect(new Rectangle(0.2f, 0.2f, 0.1f, 0.1f), Color.Red) { Rotation = 45 }; var r2 = new FilledRect(new Rectangle(0.6f, 0.6f, 0.1f, 0.2f), Color.Red) { Rotation = 70 }; r1.Start<CollidingChangesColor>(); r2.Start<CollidingChangesColor>(); new Command(point => r1.Center = point).Add(new MouseButtonTrigger(MouseButton.Left, State.Pressed)); new Command(point => r2.Center = point).Add(new MouseButtonTrigger(MouseButton.Right, State.Pressed)); }
[Test, CloseAfterFirstFrame] public void DefaultRectIsRectangleZeroAndWhite() { var rect = new FilledRect(Rectangle.One, Color.White); Assert.AreEqual(Rectangle.One, rect.DrawArea); Assert.AreEqual(Color.White, rect.Color); }
[Test, CloseAfterFirstFrame] public void RectangleCornersAreCorrect() { var rect = new FilledRect(Rectangle.One, Color.White); var corners = new List<Vector2D> { Vector2D.Zero, Vector2D.UnitY, Vector2D.One, Vector2D.UnitX }; AdvanceTimeAndUpdateEntities(); Assert.AreEqual(corners, rect.Points); }
[Test] public void ToggleRectVisibilityOnClick() { var rect = new FilledRect(Rectangle.FromCenter(Vector2D.Half, new Size(0.2f)), Color.Orange); new Command(() => ChangeVisibility(rect)).Add(new MouseButtonTrigger(MouseButton.Left, State.Releasing)); }
[Test, ApproveFirstFrameScreenshot] public void RenderRedRectOverBlue() { new FilledRect(new Rectangle(0.3f, 0.3f, 0.4f, 0.4f), Color.Red) { RenderLayer = 1 }; new FilledRect(new Rectangle(0.4f, 0.4f, 0.4f, 0.4f), Color.Blue) { RenderLayer = 0 }; }
[Test] public void RenderGrowingRotatingRectangle() { var rect = new FilledRect(new Rectangle(0.3f, 0.3f, 0.1f, 0.1f), Color.Red); rect.Start<Grow>(); }
[Test] public void RenderSpinningRectangleAttachedToMouse() { var rect = new FilledRect(new Rectangle(0.5f, 0.5f, 0.4f, 0.1f), Color.Blue); rect.Start<Spin>(); new Command(point => rect.DrawArea = Rectangle.FromCenter(point, rect.DrawArea.Size)).Add( new MouseMovementTrigger()); }
[Test, CloseAfterFirstFrame] public void RenderingHiddenRectangleDoesNotThrowException() { new FilledRect(Rectangle.One, Color.Red) { IsVisible = false }; Assert.DoesNotThrow(() => AdvanceTimeAndUpdateEntities()); }
[Test] public void RenderRectAndLine() { var drawArea = new Rectangle(0.3f, 0.3f, 0.4f, 0.4f); var rect = new FilledRect(drawArea, Color.Red); var line = new Line2D(drawArea, Color.Yellow) { RenderLayer = 1 }; new Command(Command.Drag, position => rect.Center = line.Center = position); }
[Test, CloseAfterFirstFrame] public void PointsShouldBeAddedCounterClockWise() { var filledRect = new FilledRect(new Rectangle(0.3f, 0.3f, 0.4f, 0.4f), Color.Blue); Assert.IsTrue(filledRect.Points[0].X < filledRect.Points[3].X); Assert.IsTrue(filledRect.Points[1].Y > filledRect.Points[0].Y); Assert.IsTrue(filledRect.Points[2].X > filledRect.Points[1].X); Assert.IsTrue(filledRect.Points[3].Y < filledRect.Points[2].Y); }
See Also