コード例 #1
0
        public void MatrixSaveMementoAndRestoreMementoMethodsWorkProper()
        {
            ICell[,] fieldExpected = new ICell[3, 7];

            Matrix matrix = new Matrix();

            matrix.Field = fieldExpected;

            MatrixMemento matrixMemento = matrix.SaveMemento();

            matrix.Field = new ICell[12, 18];

            matrix.RestoreMemento(matrixMemento); // Comment this row and the test will fail

            Assert.AreEqual(fieldExpected.GetLength(0), matrix.Rows, "Matrix SaveMememento and RestoreMememento doesn't work proper");
            Assert.AreEqual(fieldExpected.GetLength(1), matrix.Cols, "Matrix SaveMememento and RestoreMememento doesn't work proper");
        }
コード例 #2
0
 /// <summary>
 /// Sets the obligatory parameters needed to process the commands in the constuctor
 /// </summary>
 /// <param name="matrix">import the matrix</param>
 /// <param name="player">set the current player</param>
 /// <param name="printer">import the printer</param>
 public Command(Matrix matrix, Player player, Printer printer)
 {
     this.Matrix = matrix;
     this.Player = player;
     this.Printer = printer;
 }
コード例 #3
0
 /// <summary>
 /// Constructor for the invalid command.
 /// </summary>
 /// <param name="matrix">Current game matrix</param>
 /// <param name="player">Current game player.</param>
 /// <param name="printer">Current game printer.</param>
 public InvalidCommand(Matrix matrix, Player player, Printer printer)
     : base(matrix, player, printer)
 {
 }
コード例 #4
0
 /// <summary>
 /// Constructor for the highscore command
 /// </summary>
 /// <param name="engine">Game engine.</param>
 /// <param name="matrix">Game matrix</param>
 /// <param name="player">Current player</param>
 /// <param name="printer">Current game printer</param>
 public HighScoreCommand(MinesweeperEngine engine, Matrix matrix, Player player, Printer printer)
     : base(matrix, player, printer)
 {
     this.engine = engine;
 }
コード例 #5
0
 /// <summary>
 /// Constructor for the Save command.
 /// </summary>
 /// <param name="matrix">Current game matrix.</param>
 /// <param name="player">Current game player</param>
 /// <param name="printer">Current game printer</param>
 public SaveCommand(Matrix matrix, Player player, Printer printer)
     : base(matrix, player, printer)
 {
 }