Beispiel #1
0
        public void Test_CanAdvance_WhenNotAtTheBottomButBlockInWay_ReturnsFalse()
        {
            int blockHeight = 3;
            int fieldHeight = 10;

            Field subject = new Field(10, 10);
            subject.SetBlock(new BlockHelper.MockBlock(1, blockHeight), new Vector2(2, fieldHeight - blockHeight - 1));
            subject.SetContentsForTest(new Color?[,]{
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,Color.Red},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null},
                {null,null,null,null,null,null,null,null,null,null}
            });

            Assert.That(subject.CanAdvance(), Is.False);
        }
        public void Test_ColorAt_WhenBlockIsThereAndNoColor_ItReturnsFieldColorAt()
        {
            Field subject = new Field(4, 4);
            Color white = Color.White;

            subject.SetContentsForTest(new Color?[,]
            { { null, null,  null,  null},
              { null, white, white, null },
              { null, white, white, null },
              { null, null,  null,  null} });

            Mock<IBlock> block = new Mock<IBlock>();
            Color? nullColor = null;

            block.Setup(b => b.Width).Returns(2);
            block.Setup(b => b.Height).Returns(2);
            block.Setup(b => b.ColorAt(new Vector2(0, 1))).Returns(nullColor);

            subject.SetBlock(block.Object, new Vector2(1, 1));

            Color? result = subject.ColorAt(new Vector2(1, 2));
            Assert.AreEqual(Color.White, result.Value);
        }
Beispiel #3
0
        public void Test_SetContentsForTest()
        {
            Field subject = new Field(2, 2);

            subject.SetContentsForTest(new Color?[,] {
                { Color.Red, null },
                { null, Color.Blue }
            });

            Assert.AreEqual(Color.Red, subject.ColorAt(new Vector2(0, 0)));
            Assert.AreEqual(Color.Blue, subject.ColorAt(new Vector2(1, 1)));
            Assert.IsNull(subject.ColorAt(new Vector2(0, 1)));
            Assert.IsNull(subject.ColorAt(new Vector2(1, 0)));
        }
Beispiel #4
0
        public void Test_CanRotateRight_RightSideNotFreeToRotate_ReturnsFalse()
        {
            int blockHeight = 2;

            Field subject = new Field(3, 3);
            subject.SetBlock(new BlockHelper.MockBlock(1, blockHeight), new Vector2(1, 0));
            subject.SetContentsForTest(new Color?[,]{
                {null,null,null},
                {null,null,null},
                {null,null,null}
            });

            Assert.That(subject.CanRotateRight(), Is.True);
        }