コード例 #1
0
ファイル: MatrixTests.cs プロジェクト: xwind13/BricksGame
        public void ShouldThrowExIfRangeOut()
        {
            var items = new TestValue[, ] {
                { new TestValue(1), new TestValue(2), new TestValue(3) }
            };
            var chainedMatrix = new LBChainedMatrix <TestValue>(new Matrix <TestValue>(items));

            Assert.Throws <IndexOutOfRangeException>(() => chainedMatrix[50, 50]);
        }
コード例 #2
0
ファイル: MatrixTests.cs プロジェクト: xwind13/BricksGame
        public void ShouldThrowExIfMoveUnknownDirection()
        {
            var items = new TestValue[, ] {
                { new TestValue(1), new TestValue(2), new TestValue(3) }
            };
            var chainedMatrix = new LBChainedMatrix <TestValue>(new Matrix <TestValue>(items));

            var item = chainedMatrix[0, 0];

            Assert.Throws <KeyNotFoundException>(() => item.Next(Direction.None));
        }
コード例 #3
0
ファイル: MatrixTests.cs プロジェクト: xwind13/BricksGame
        public void ShouldCreateChainedMatrix(TestValue[,] items)
        {
            var chainedMatrix = new LBChainedMatrix <TestValue>(new Matrix <TestValue>(items));

            for (uint i = 0; i < chainedMatrix.Width; i++)
            {
                for (uint j = 0; j < chainedMatrix.Height; j++)
                {
                    chainedMatrix[i, j].Value.ShouldBe(items[i, j]);
                }
            }
        }
コード例 #4
0
ファイル: MatrixTests.cs プロジェクト: xwind13/BricksGame
        public void ShouldMoveByLinksVertically__LeftBottomCS(TestValue[,] items)
        {
            var chainedMatrix = new LBChainedMatrix <TestValue>(new Matrix <TestValue>(items));

            for (uint i = 0; i < chainedMatrix.Width; i++)
            {
                uint j        = 0;
                var  nextLink = chainedMatrix[i, j];
                nextLink.Value.ShouldBe(items[i, j]);

                while ((nextLink = nextLink.Next(Direction.Up)) != null)
                {
                    j++;
                    nextLink.Value.ShouldBe(items[i, j]);
                }

                j.ShouldBe(chainedMatrix.Height - 1);
            }
        }
コード例 #5
0
ファイル: MatrixTests.cs プロジェクト: xwind13/BricksGame
        public void ShouldMoveByLinksOppositeHorizontally__LeftBottomCS(TestValue[,] items)
        {
            var chainedMatrix = new LBChainedMatrix <TestValue>(new Matrix <TestValue>(items));

            for (uint j = 0; j < chainedMatrix.Height; j++)
            {
                uint i        = chainedMatrix.Width - 1;
                var  nextLink = chainedMatrix[i, j];
                nextLink.Value.ShouldBe(items[i, j]);

                while ((nextLink = nextLink.Next(Direction.Left)) != null)
                {
                    i--;
                    nextLink.Value.ShouldBe(items[i, j]);
                }

                i.ShouldBe((uint)0);
            }
        }
コード例 #6
0
ファイル: MatrixTests.cs プロジェクト: xwind13/BricksGame
        public void ShouldChangeLinkedValue()
        {
            var items = new TestValue[, ] {
                { new TestValue(1), new TestValue(2), new TestValue(3) }
            };
            var chainedMatrix = new LBChainedMatrix <TestValue>(new Matrix <TestValue>(items));

            int newValue = 59;

            chainedMatrix.ForEach((linkItem) => linkItem.Value.Value = newValue);

            for (uint i = 0; i < chainedMatrix.Width; i++)
            {
                for (uint j = 0; j < chainedMatrix.Height; j++)
                {
                    chainedMatrix[i, j].Value.Value.ShouldBe(newValue);
                    chainedMatrix[i, j].Value.ShouldBe(items[i, j]);
                }
            }
        }