Exemplo n.º 1
0
        public void ShouldCreateMatrix()
        {
            var items = new TestValue[3, 2];

            var matrix = new Matrix <TestValue>(items);

            matrix.Height.ShouldBe((uint)2);
            matrix.Width.ShouldBe((uint)3);
        }
Exemplo n.º 2
0
        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]);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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]);
                }
            }
        }