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