Example #1
0
        public void ConflictHelperGetExistingConflicts()
        {
            var position = new Vector2(0, 0);
            var left     = new IDrawableMock()
            {
                Position = position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };
            var right = new IDrawableMock()
            {
                Position = position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };
            var third = new IDrawableMock()
            {
                Position = position + new Vector2(OBJECT_WIDTH, OBJECT_HEIGHT), Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };

            Assert.IsTrue(this.ConflictHelper.CheckConflict(left, right));
            Assert.IsFalse(this.ConflictHelper.CheckConflict(left, third));

            var result = this.ConflictHelper.GetConflictingVertices(left, new List <IDrawable> {
                right, third
            });

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 1);
            Assert.AreEqual(result[0], right);
        }
Example #2
0
        public void InitializeDrawables()
        {
            Left = new IDrawableMock
            {
                Width  = DRAWABLE_WIDTH,
                Height = DRAWABLE_HEIGHT
            };

            Right = new IDrawableMock
            {
                Width  = DRAWABLE_WIDTH,
                Height = DRAWABLE_HEIGHT
            };
        }
Example #3
0
        public void ConflictHelperCheckNonExistingConflicts()
        {
            var position = new Vector2(OBJECT_WIDTH, OBJECT_HEIGHT);
            var left     = new IDrawableMock()
            {
                Position = position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };
            var right = new IDrawableMock()
            {
                Position = 2 * position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };

            Assert.IsFalse(this.ConflictHelper.CheckConflict(left, right));
        }
Example #4
0
        public void PositionHelperGetPaddingY()
        {
            var left = new IDrawableMock()
            {
                Position = new Vector2(0, 0), Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };
            var right = new IDrawableMock()
            {
                Position = new Vector2(0, 100), Width = OBJECT_WIDTH / 3, Height = OBJECT_HEIGHT / 3
            };

            var result = this.PositionHelper.GetPaddingY(left, right, HEIGHT);

            Assert.IsTrue(result != 0);
            Assert.AreEqual(((right.Position.Value.Y + right.Height) / 2 + left.Position.Value.Y + result), HEIGHT / 2);
        }
Example #5
0
        public void ConflictHelperResolveHorizontalExistingConflict()
        {
            var position = new Vector2(0, 0);
            var left     = new IDrawableMock()
            {
                Position = position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };
            var right = new IDrawableMock()
            {
                Position = position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };

            Assert.IsTrue(this.ConflictHelper.CheckConflict(left, right));

            this.ConflictHelper.ResolveHorizontalConflict(left, right);
            Assert.IsFalse(this.ConflictHelper.CheckConflict(left, right));
        }
Example #6
0
        public void ConflictHelperGetOverlapY()
        {
            var position = new Vector2(0, 0);
            var left     = new IDrawableMock()
            {
                Position = position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };
            var right = new IDrawableMock()
            {
                Position = position, Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };

            Assert.IsTrue(this.ConflictHelper.CheckConflict(left, right));

            var result = this.ConflictHelper.GetOverlapY(left, right);

            Assert.IsTrue(result.Y >= OBJECT_HEIGHT);
        }
        public void DrawableHelperCombineTest()
        {
            var left = new IDrawableMock()
            {
                Width = WIDTH, Height = HEIGHT, Position = new Vector2(0, 0)
            };
            var right = new IDrawableMock()
            {
                Width = WIDTH, Height = HEIGHT, Position = new Vector2(WIDTH, 0)
            };

            this.DrawableHelper.CombineIntoGroup(left, right);
            Assert.AreEqual(left.Group, right.Group);
            Assert.AreEqual(left.Group.Width, 2 * WIDTH);
            Assert.AreEqual(left.Group.Height, HEIGHT);
            Assert.AreEqual(left.Group.Position, left.Position);

            left.Group     = null;
            right.Group    = null;
            right.Position = new Vector2(0, HEIGHT);
            this.DrawableHelper.CombineIntoGroup(left, right);
            Assert.AreEqual(left.Group, right.Group);
            Assert.AreEqual(left.Group.Width, WIDTH);
            Assert.AreEqual(left.Group.Height, 2 * HEIGHT);
            Assert.AreEqual(left.Group.Position, left.Position);

            left.Group    = null;
            left.Position = new Vector2(WIDTH, 0);
            this.DrawableHelper.CombineIntoGroup(left, right);
            Assert.AreEqual(left.Group, right.Group);
            Assert.AreEqual(left.Group.Width, 2 * WIDTH);
            Assert.AreEqual(left.Group.Height, 2 * HEIGHT);
            Assert.AreEqual(left.Group.Position, new Vector2(0, 0));

            right.Group    = null;
            right.Position = new Vector2(WIDTH, 0);
            this.DrawableHelper.CombineIntoGroup(left, right);
            Assert.AreEqual(left.Group, right.Group);
            Assert.AreEqual(left.Group.Width, 2 * WIDTH);
            Assert.AreEqual(left.Group.Height, 2 * HEIGHT);
            Assert.AreEqual(left.Group.Position, new Vector2(0, 0));
        }
Example #8
0
        public void PositionHelperGetEmptyPosition()
        {
            var left = new IDrawableMock()
            {
                Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };
            var right = new IDrawableMock()
            {
                Width = OBJECT_WIDTH, Height = OBJECT_HEIGHT
            };

            var leftPos  = this.PositionHelper.GetEmptyPosition(left);
            var rightPos = this.PositionHelper.GetEmptyPosition(right);

            left.Position  = leftPos;
            right.Position = rightPos;

            Assert.IsNotNull(leftPos);
            Assert.IsNotNull(rightPos);
            Assert.AreNotEqual(leftPos, rightPos);
            Assert.IsTrue(leftPos.Value.X + left.Width <= rightPos.Value.X);
            Assert.IsFalse(this.ConflictHelper.CheckConflict(left, right));
        }
 public void InitializeDrawables()
 {
     Left    = new IDrawableMock();
     Right   = new IDrawableMock();
     Factory = new EdgeFactory();
 }