示例#1
0
 public void PlayerAddDetonatedMines()
 {
     Player player = new Player("Ivan");
     player.DetonatedMines = 12;
     player.AddDetonatedMines(1);
     Assert.AreEqual(13, player.DetonatedMines);
 }
示例#2
0
 public void PlayerDetonatedMinesSetterTest()
 {
     string name = "Ivan";
     int expected = 10;
     Player player = new Player(name);
     player.DetonatedMines = expected;
     Assert.AreEqual(expected, player.DetonatedMines);
 }
示例#3
0
 public void PlayerDetonatedMinesIfSetterAcceptNegativeValue()
 {
     string name = "Ivan";
     string message = string.Empty;
     Player player = new Player(name);
     Assert.AreEqual(name, player.Name);
     try
     {
         player.DetonatedMines = -1;
     }
     catch (ArgumentOutOfRangeException ex)
     {
         message = "Error:" + ex.ToString();
         Console.WriteLine(message);
     }
     StringAssert.Contains(message, "Error");
 }
示例#4
0
        public void PlayerDetonatedMinesIfSetterAcceptGreaterThanMaxValue()
        {
            string name = "Ivan";
            string message = string.Empty;
            Player player = new Player(name);
            Assert.AreEqual(name, player.Name);

            try
            {
                player.DetonatedMines = 101;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                message = "Error " + ex.ToString();
            }
            StringAssert.Contains(message, "Error");
        }
示例#5
0
        /// <summary>
        /// Starts the game.
        /// </summary>
        /// <param name="isLoadGameChosen">Check if a load game is chosen.</param>
        private void Initialize(bool isLoadGameChosen)
        {
            this.gameSaver = new SaveLoadAPI();
            this.gamePlayer = new Player("Pesho");

            if (isLoadGameChosen)
            {
                this.gameSaver.LoadGame();
                this.PlayField = this.InitializeField(this.gameSaver.MementoField.FieldDimension);
                this.PlayField.LoadMemento(this.gameSaver.MementoField);
            }
            else
            {
                this.PlayField = this.GetNewField();
            }

            this.CurrentCell = this.PlayField[0, 0];
            this.SoundsPlayer = this.GetNewSoundsPlayer();
            this.Pointer = new Pointer(this.playField[0, 0].X, this.playField[0, 0].Y);
        }
示例#6
0
 public void PlayerIfSetterAcceptEmptyString()
 {
     string name = "Ivan";
     string message = string.Empty;
     Player player = new Player(name);
     Assert.AreEqual(name, player.Name);
     player.MovesCount = 1;
     Assert.AreEqual(1, player.MovesCount);
     try
     {
         player.Name = string.Empty;
     }
     catch (ArgumentNullException ex)
     {
         message = ex.ToString();
     }
     StringAssert.Contains(message, "Error");
 }
示例#7
0
 public void PlayerAddMove()
 {
     Player player = new Player("Ivan");
     player.AddMove();
     Assert.AreEqual(1, player.MovesCount);
 }
示例#8
0
 public void PlayerToString()
 {
     Player player = new Player("Ivan");
     player.DetonatedMines = 12;
     player.AddDetonatedMines(1);
     player.AddMove();
     Assert.AreEqual("Player: Ivan, Detonated mines: 13, Moves: 1", player.ToString(), "Equals");
 }
示例#9
0
        public void PlayerSaveMemento()
        {
            Player player = new Player("Ivan");
            player.DetonatedMines = 12;
            player.MovesCount = 11;
            MementoPlayer mementoPlayer = player.SaveMemento();

            Assert.AreEqual("Ivan", mementoPlayer.Name);
            Assert.AreEqual(12, mementoPlayer.DetonatedMines);
            Assert.AreEqual(11, mementoPlayer.MovesCount);
        }
示例#10
0
        public void PlayerRestoreMemento()
        {
            Player player = new Player("Ivan");
            player.DetonatedMines = 12;
            player.MovesCount = 11;
            MementoPlayer mementoPlayer = new MementoPlayer();

            player.LoadMemento(mementoPlayer);
        }
示例#11
0
 public void PlayerNameSetterTest()
 {
     string name = "Ivan";
     Player player = new Player(name);
     Assert.AreEqual(name, player.Name);
 }
示例#12
0
        public void PlayerMovesLessThanZero()
        {
            string message = string.Empty;
            string name = "Ivan";
            Player player = new Player(name);
            Assert.AreEqual(name, player.Name);
            player.MovesCount = 1;
            Assert.AreEqual(1, player.MovesCount);

            try
            {
                player.MovesCount = -1;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                message = "Error " + ex.ToString();
            }
            StringAssert.Contains(message, "Error");
        }
示例#13
0
 public void PlayerMovesGreaterThanZero()
 {
     Player player = new Player("Ivan");
     player.MovesCount = 1;
     Assert.AreEqual(1, player.MovesCount);
 }