Beispiel #1
0
        public void VerifyThatListOfItemsIsSuitablyAdjustedWhenGameObjectMovesFromAnAdditionalOccupiedSpaceToFreeSpace()
        {
            var g = new GameForUnitTests();

            var instructions = new[]
            {
                new PlayerController.TimedInstruction(TimeSpan.Zero, PlayerController.Instruction.Move(Direction.Right))
            };

            g.UnitTestServices.PlayerController.Enqueue(instructions);

            g.LoadLevel("p ");
            GlobalServices.GameState.AddGrave(new TilePos(0, 0));

            g.RunTest();

            var list = GlobalServices.GameState.GetItemsOnTile(new TilePos(0, 0)).ToList();

            Assert.IsNotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Grave);

            list = GlobalServices.GameState.GetItemsOnTile(new TilePos(1, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Player);
        }
Beispiel #2
0
        public void TestPlayerCannotShootBoulder3()
        {
            var g = new GameForUnitTests();

            var instructions = new[]
            {
                new PlayerController.TimedInstruction(TimeSpan.Zero, PlayerController.Instruction.Fire(Direction.Left))
            };

            g.UnitTestServices.PlayerController.Enqueue(instructions);

            g.LoadLevel("# bbp ");

            g.RunTest();

            Assert.IsFalse(GlobalServices.GameState.DoesShotExist());
            var list = GlobalServices.GameState.GetItemsOnTile(new TilePos(2, 0)).ToList();

            Assert.IsNotEmpty(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Boulder);
            list = GlobalServices.GameState.GetItemsOnTile(new TilePos(3, 0)).ToList();
            Assert.IsNotEmpty(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Boulder);
        }
        public void TestPlayerBouncesOneBoulderAndEndsUpPushingAnother()
        {
            var g = new GameForUnitTests();

            var instructions = new[]
            {
                new PlayerController.TimedInstruction(TimeSpan.Zero, PlayerController.Instruction.Move(Direction.Left))
            };

            g.UnitTestServices.PlayerController.Enqueue(instructions);

            g.LoadLevel("#bpb #");

            g.RunTest();

            var list = GlobalServices.GameState.GetItemsOnTile(new TilePos(1, 0)).ToList();

            Assert.NotNull(list);
            Assert.IsEmpty(list);

            list = GlobalServices.GameState.GetItemsOnTile(new TilePos(2, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Boulder);

            list = GlobalServices.GameState.GetItemsOnTile(new TilePos(3, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Player);

            list = GlobalServices.GameState.GetItemsOnTile(new TilePos(4, 0)).ToList();
            Assert.NotNull(list);
            Assert.AreEqual(1, list.Count);
            Assert.IsTrue(list[0] is Boulder);
        }
        public void TestPlayerHasNoSpaceToBounceBoulder()
        {
            var g = new GameForUnitTests();

            g.LoadLevel("#bp#");
            var p = GlobalServices.GameState.Player;

            Assert.IsFalse(p.CanMoveInDirection(Direction.Left));

            var boulder = (Boulder)GlobalServices.GameState.GetItemsOnTile(new TilePos(1, 0)).ElementAt(0);

            boulder.PushOrBounce(p, Direction.Left);

            Assert.AreEqual(Direction.None, p.CurrentMovement.Direction);
            Assert.AreEqual(Direction.None, boulder.CurrentMovement.Direction);
        }
        public void TestPlayerCannotBouncesOneBoulderBecauseAnotherBoulderBehindCannotMove()
        {
            var g = new GameForUnitTests();

            g.LoadLevel("#bpb#");
            var p = GlobalServices.GameState.Player;

            Assert.IsFalse(p.CanMoveInDirection(Direction.Left));

            var boulder1 = (Boulder)GlobalServices.GameState.GetItemsOnTile(new TilePos(1, 0)).ElementAt(0);

            boulder1.PushOrBounce(p, Direction.Left);
            Assert.AreEqual(Direction.None, p.CurrentMovement.Direction);

            Assert.AreEqual(Direction.None, boulder1.CurrentMovement.Direction);
        }
Beispiel #6
0
        public void VerifyThatTheListOfItemsMovesWhenGameObjectMovesToAnAdjacentEmptySpace()
        {
            var g = new GameForUnitTests();

            var instructions = new[]
            {
                new PlayerController.TimedInstruction(TimeSpan.Zero, PlayerController.Instruction.Move(Direction.Right))
            };

            g.UnitTestServices.PlayerController.Enqueue(instructions);

            g.LoadLevel("p ");
            var p = GlobalServices.GameState.Player;

            g.RunTest();

            Assert.IsEmpty(GlobalServices.GameState.GetItemsOnTile(new TilePos(0, 0)));
            var list = GlobalServices.GameState.GetItemsOnTile(new TilePos(1, 0)).ToList();

            Assert.IsNotEmpty(list);
            Assert.IsTrue(list.SequenceEqual(new List <StaticItem> {
                p
            }));
        }