public void GetMementoShouldReturnDifferentInstanceOfMatrix() { var memory = new FieldMemory(filledMatrix); var savedMatrix = memory.GetMemento(); Assert.AreNotSame(filledMatrix, savedMatrix); }
/// <summary> /// Method which manages saving field. /// </summary> /// <param name="gameField">The field to be saved.</param> public void Save(IMemorable gameField) { if (ObjectValidator.IsGameObjectNull(gameField)) { throw new ArgumentNullException(GameFieldNullErrorMessage); } this.Memory = gameField.SaveField(); }
public void GetMementoShouldReturnNonEmptyMatrixWhenSuchPassed() { var memory = new FieldMemory(filledMatrix); var savedMatrix = memory.GetMemento(); var expectedResult = true; for (int i = 0; i < savedMatrix.GetLength(0); i++) { for (int j = 0; j < savedMatrix.GetLength(1); j++) { if (savedMatrix[i, i] == null) { expectedResult = false; } } } Assert.IsTrue(expectedResult); }
public FieldMemory SaveField() { var fieldCopy = (Balloon[,])this.fieldMatrix.Clone(); var memento = new FieldMemory(fieldCopy); return memento; }
public void RestoreField(FieldMemory memento) { this.fieldMatrix = memento.GetMemento(); }