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); }
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]); }
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)); }
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]); } } }