public void ShouldMatrixStateManagerRestoreToPreviousStates() { var matrix = new Matrix <TestStateValue>(GetTestMatrixValues()); var matrixStateManager = new MatrixStateManager <TestStateValue>(matrix, 2); matrixStateManager.Save(); matrix.ForEach((item, x, y) => item.Value = (int)(2 * x)); matrixStateManager.Save(); matrix.ForEach((item, x, y) => item.Value = (int)(3 * x)); matrixStateManager.Save(); matrix.ForEach((item, x, y) => item.Value = (int)(4 * x)); matrix.ForEach((item, x, y) => item.Value.ShouldBe((int)(4 * x))); var result = matrixStateManager.BackToPrevious(); result.ShouldBeTrue(); matrix.ForEach((item, x, y) => item.Value.ShouldBe((int)(3 * x))); result = matrixStateManager.BackToPrevious(); result.ShouldBeTrue(); matrix.ForEach((item, x, y) => item.Value.ShouldBe((int)(2 * x))); result = matrixStateManager.BackToPrevious(); result.ShouldBeFalse(); matrix.ForEach((item, x, y) => item.Value.ShouldBe((int)(2 * x))); }
public void ShouldMatrixStateManagerNotChangeMatrixValuesIfNotSavedStates() { var matrix = new Matrix <TestStateValue>(GetTestMatrixValues()); var matrixStateManager = new MatrixStateManager <TestStateValue>(matrix, 2); var result = matrixStateManager.BackToPrevious(); result.ShouldBeFalse(); matrix.ForEach((item, x, y) => item.Value.ShouldBe((int)x)); }