Example #1
0
        public void FleeFunctionalityTest()
        {
            Maze   m = new Maze(Game.Width, Game.Height, 0, 0);
            Player p = CharacterTests.CreatePlayerCharacter();

            p.CurrentRoom = new Room("", new Point(0, 0));
            int oldX = p.CurrentRoom.LocationOfRoom.X;
            int oldY = p.CurrentRoom.LocationOfRoom.Y;

            p.Flee(m);
            bool different = p.CurrentRoom.LocationOfRoom.X != oldX | p.CurrentRoom.LocationOfRoom.Y != oldY;

            Assert.IsTrue(different);
        }
Example #2
0
        public void UnarmedPlayerDescriptionIsCorrect()
        {
            Player p = CharacterTests.CreatePlayerCharacter();

            p.EquippedWeapon = null;
            using (StringWriter consoleOutput = new StringWriter())
            {
                Console.SetOut(consoleOutput);
                p.PrintStats();
                Assert.AreEqual(p.Name + ": "
                                + p.Description +
                                "\r\nHealth: 100" +
                                "\r\nStrength: " + p.Strength +
                                "\r\nUnarmed.\r\n\r\n", consoleOutput.ToString());
            }
        }
Example #3
0
        public void WeaponDescriptionIsCorrect()
        {
            Player p              = CharacterTests.CreatePlayerCharacter();
            string gunName        = "gun";
            string gunDescription = "description";

            p.EquippedWeapon = new Weapon(gunName, 1, gunDescription);
            using (StringWriter consoleOutput = new StringWriter())
            {
                Console.SetOut(consoleOutput);
                p.EquippedWeapon.PrintStats();
                Assert.AreEqual(gunName + ": " + gunDescription +
                                "\r\nStrength: " + p.EquippedWeapon.Strength +
                                "\r\n", consoleOutput.ToString());
            }
        }
Example #4
0
 public void ArmedPlayerDescriptionIsCorrect()
 {
     using (StringWriter consoleOutput = new StringWriter())
     {
         Player p = CharacterTests.CreatePlayerCharacter();
         Console.SetOut(consoleOutput);
         p.PrintStats();
         string expectedResult = p.Name + ": "
                                 + p.Description +
                                 "\r\nHealth: 100" +
                                 "\r\nStrength: " + p.Strength +
                                 "\r\nCurrent weapon:" +
                                 "\r\n" + p.EquippedWeapon.Name + ": " + p.EquippedWeapon.Description +
                                 "\r\nStrength: " + p.EquippedWeapon.Strength + "\r\n\r\n";
         Assert.AreEqual(expectedResult, consoleOutput.ToString());
     }
 }