/// <summary> /// Restore previously state of PlayField.Instance /// </summary> /// <param name="memento"></param> public void LoadMemento(MementoField memento) { if (memento == null) { throw new ArgumentNullException("Error: loaded memento object cannot be null!"); } this.cells = this.CloneToMultiDimArray(memento.ZeroBasedPlayField, memento.FieldDimension); }
public void SaveMethodCannotReturnMementoWithNullZeroBaseArray() { Playfield testField = Playfield.Instance; testField.SetFieldSize(5); testField.InitializeEmptyField(); testField.PlaceMines(); MementoField memento = new MementoField(); memento = testField.SaveMemento(); Assert.IsNotNull(memento.ZeroBasedPlayField, "Zero-based playfield backup cannot be null"); }
/// <summary> /// Returns MementoField instance that keeps the current state of the Playfield.Instance /// </summary> /// <returns></returns> public MementoField SaveMemento() { if (cells == null) { throw new ArgumentNullException("Error: playfiled array cannot be null (not initialized)"); } MementoField memento = new MementoField(); memento.ZeroBasedPlayField = CloneToZeroBasedArray(this.cells as Cell[, ]); memento.FieldDimension = this.PlayfieldSize; return(memento); }
public void FieldDimensionsSetterThrowExeptionIfArgsIsOutOfRange() { MementoField mementoField = new MementoField(); mementoField.FieldDimension = 11; }
public void ZeroBasedPlayfieldThrowsExecptionIfSetterAcceptNull() { MementoField mementoField = new MementoField(); mementoField.ZeroBasedPlayField = null; }
/// <summary> /// Returns MementoField instance that keeps the current state of the Playfield.Instance /// </summary> /// <returns></returns> public MementoField SaveMemento() { if (cells == null) { throw new ArgumentNullException("Error: playfiled array cannot be null (not initialized)"); } MementoField memento = new MementoField(); memento.ZeroBasedPlayField = CloneToZeroBasedArray(this.cells as Cell[,]); memento.FieldDimension = this.PlayfieldSize; return memento; }