Esempio n. 1
0
        public void TestDrawAreaWhenChangingOrientation(Type type)
        {
            var rect = new Rect(new Point(0.7f, 0.7f), new Size(0.1f, 0.1f), Color.Red);
            Start(type, (Renderer testRenderer) => testRenderer.Add(rect),
                (Window testWindow, ScreenSpace screen) =>
                {
                    testWindow.TotalPixelSize = new Size(480, 800);

                    var quadSize = screen.FromPixelSpace(new Point(0, 0));
                    Assert.IsTrue(quadSize.X.IsNearlyEqual(0.2f));
                    Assert.AreEqual(0, quadSize.Y);
                    quadSize = screen.FromPixelSpace(new Point(480, 800));
                    Assert.AreEqual(new Point(0.8f, 1), quadSize);

                    var pixelSize = screen.ToPixelSpace(new Point(0.2f, 0));
                    Assert.AreEqual(Point.Zero, pixelSize);
                    pixelSize = screen.ToPixelSpace(new Point(0.8f, 1));
                    Assert.AreEqual(new Point(480, 800), pixelSize);

                    testWindow.TotalPixelSize = new Size(800, 480);

                    quadSize = screen.FromPixelSpace(new Point(0, 0));
                    Assert.AreEqual(new Point(0f, 0.2f), quadSize);
                    quadSize = screen.FromPixelSpace(new Point(800, 480));
                    Assert.AreEqual(new Point(1, 0.8f), quadSize);

                    pixelSize = screen.ToPixelSpace(new Point(0f, 0.2f));
                    Assert.AreEqual(Point.Zero, pixelSize);
                    pixelSize = screen.ToPixelSpace(new Point(1, 0.8f));
                    Assert.AreEqual(new Point(800, 480), pixelSize);
                });
        }
Esempio n. 2
0
 public void CreateFromRectangle(Type resolver)
 {
     var halfScreenRect = new Rectangle(Point.Zero, Size.Half);
     Rect box = null;
     Start(resolver, (Renderer r) => r.Add(box = new Rect(halfScreenRect, Color.Red)),
         () => Assert.AreEqual(Color.Red, box.Color));
 }
Esempio n. 3
0
 public void RedBoxOverLaysBlueBox(Type resolver)
 {
     Start(resolver, (Renderer r) =>
     {
         var redBox = new Rect(new Point(0.4f, 0.4f), Size.Half, Color.Red) { RenderLayer = 1 };
         var blueBox = new Rect(new Point(0.5f, 0.6f), Size.Half, Color.Blue) { RenderLayer = 2 };
         r.Add(redBox);
         r.Add(blueBox);
         redBox.RenderLayer = 3;
     });
 }
Esempio n. 4
0
 public void AdddingBoxTwiceWillOnlyDisplayItOnce(Type resolver)
 {
     Rect box = null;
     Start(resolver, (Renderer r) =>
     {
         box = new Rect(Point.Half, Size.Half, Color.Yellow);
         r.Add(box);
         box.DrawArea.Center = new Point(0.6f, 0.6f);
         box.Color = Color.Teal;
         r.Add(box);
     }, () => Assert.AreEqual(Color.Teal, box.Color));
 }
Esempio n. 5
0
        public void GraphicalUnitTest(Type resolver)
        {
            Rect rectangle = null;
            var currentPosition = new Point(0.1f, 0.1f);

            Start(resolver, (Renderer renderer, InputCommands input) =>
            {
                rectangle = new Rect(Point.Zero, new Size(0.1f, 0.1f), Color.Red);
                renderer.Add(rectangle);
                input.Add(Key.A, State.Pressing, () => currentPosition = new Point(0.6f, 0.5f));
                input.Add(Key.A, State.Released, () => currentPosition = new Point(0.1f, 0.1f));
            }, () => rectangle.DrawArea.TopLeft = currentPosition);
        }
Esempio n. 6
0
 public void GraphicalUnitTest(Type resolver)
 {
     Rect rect = null;
     Touch currentTouch = null;
     Start(resolver, (Renderer renderer, Touch touch) =>
     {
         currentTouch = touch;
         rect = new Rect(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Red);
         renderer.Add(rect);
     },
     delegate
     {
         Point position = currentTouch.GetPosition(0);
         rect.DrawArea.Left = position.X;
         rect.DrawArea.Top = position.Y;
     });
 }
Esempio n. 7
0
        public void GraphicalUnitTest(Type resolver)
        {
            Rect rect = null;
            Mouse remMouse = null;

            Start(resolver, (Renderer renderer, Mouse mouse, Window window) =>
            {
                window.Title = "Click to draw";
                remMouse = mouse;
                rect = new Rect(new Rectangle(-0.1f, -0.1f, 0.1f, 0.1f), Color.Red);
                renderer.Add(rect);
            }, delegate
            {
                var position = remMouse.LeftButton == State.Pressed ? remMouse.Position : -Point.Half;
                rect.DrawArea.Left = position.X;
                rect.DrawArea.Top = position.Y;
            });
        }
Esempio n. 8
0
        public void GraphicalUnitTest(Type resolver)
        {
            Rect rect = null;
            GamePad remGamepad = null;

            Start(resolver, (Renderer renderer, GamePad gamepad) =>
            {
                remGamepad = gamepad;
                rect = new Rect(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.GetRandomBrightColor());
                renderer.Add(rect);
            }, delegate
            {
                var position = remGamepad.GetButtonState(GamePadButton.X) == State.Pressed
                    ? Point.Half : Point.Zero;
                rect.DrawArea.Left = position.X;
                rect.DrawArea.Top = position.Y;
                rect.Color = Color.GetRandomBrightColor();
            });
        }
Esempio n. 9
0
        public void GraphicalUnitTest(Type resolver)
        {
            Rect rect = null;
            Keyboard remKeyboard = null;

            Start(resolver, (Renderer renderer, Keyboard keyboard) =>
            {
                remKeyboard = keyboard;
                rect = new Rect(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f),
                    Color.GetRandomBrightColor());
                renderer.Add(rect);
            }, delegate
            {
                var position = remKeyboard.GetKeyState(Key.A) == State.Pressed ? Point.Half : Point.Zero;
                rect.DrawArea.Left = position.X;
                rect.DrawArea.Top = position.Y;
                rect.Color = Color.GetRandomBrightColor();
            });
        }
Esempio n. 10
0
 public void CreateFromPointAndSize(Type resolver)
 {
     Rect box = null;
     Start(resolver, (Renderer r) => r.Add(box = new Rect(Point.Half, Size.Half, Color.Red)),
         () => Assert.AreEqual(Color.Red, box.Color));
 }