public void TestConstructorWhenPassNullShouldThrowException()
        {
            var rng = new RandomNumberGenerator();
            SmallPlayfield playfield = null;

            var memento = new Memento(playfield);
        }
 /// <summary>
 /// Serialize object in binary format
 /// </summary>
 /// <param name="serializableObject">Object that will be serialized</param>
 /// <param name="fileName">Name of binary file</param>
 public void SerializeObject(Memento serializableObject, string fileName)
 {
     IFormatter formatter = new BinaryFormatter();
     Stream stream = new FileStream(
                             fileName,
                              FileMode.Create,
                              FileAccess.Write,
                              FileShare.None);
     formatter.Serialize(stream, serializableObject);
     stream.Close();
 }
        public void TestConstructorShouldCopyCorrectPlayfield()
        {
            var rng = new RandomNumberGenerator();
            var playfield = new SmallPlayfield();
            playfield.FillPlayfield(rng);

            var memento = new Memento(playfield);
            bool areEqual = true;

            for (int row = 0; row < playfield.Size; row++)
            {
                for (int col = 0; col < playfield.Size; col++)
                {
                    if (playfield.GetCell(row, col) != memento.Grid[row, col])
                    {
                        areEqual = false;
                    }
                }
            }

            Assert.IsTrue(areEqual);
        }
        /// <summary>
        /// Restote previous saved state of playfield
        /// </summary>
        /// <param name="memento">Memento object that will restore previous state of playfield</param>
        public void RestoreMemento(Memento memento)
        {
            this.grid = new string[this.size, this.size];

            for (int row = 0; row < this.size; row++)
            {
                for (int col = 0; col < this.size; col++)
                {
                    this.grid[row, col] = memento.Grid[row, col];
                }
            }
        }