Esempio n. 1
0
        public void HasSamePositionAt_NOT_Touched_Diagonal_Test()
        {
            VModel model = new VModel();

            Point size = new Point();
            size.X = 100;
            size.Y = 50;

            model.Map = new Map2d(size);

            // Insert a Wall exactly in the middle (vertical)
            model.Map.InsertWall(new Wall() { Start = new Point(50, 0), End = new Point(50, 50) });

            // Presume that the first id's are reserved for players
            ModelPlayer player = new ModelPlayer(model, 0, 10);

            // Create Coins
            ModelObject target = new ModelObject(model, 10, 2);

            // Add objects to model
            model.AddModelObject(target, new Point(10, 10));
            model.AddModelObject(player, new Point(20, 20)); // tight but NOT 'on' the coin (=> which through (int) is ON the coin!)

            bool result = target.hasSamePosition(player);

            Assert.AreEqual(false, result);
        }
Esempio n. 2
0
        public void GetCloseModelObjects_Test()
        {
            VModel model = new VModel();

            Point size = new Point();
            size.X = 100;
            size.Y = 50;

            model.Map = new Map2d(size);

            // [TARGET of Test] Presume that the first id's are reserved for players
            ModelPlayer player = new ModelPlayer(model, 0, 10);

            // Create Coins
            ModelCoin coin_0 = new ModelCoin(model, 10, 2);
            ModelCoin coin_1 = new ModelCoin(model, 11, 2);
            ModelCoin coin_2 = new ModelCoin(model, 12, 2);
            ModelCoin coin_3 = new ModelCoin(model, 13, 2);

            // Add objects to model
            model.AddModelObject(player, new Point(10, 10));
            model.AddModelObject(coin_0, new Point(18, 18)); // should be neighbour
            model.AddModelObject(coin_1, new Point(8, 8)); // should be neighbour
            model.AddModelObject(coin_2, new Point(30, 30)); // should still be neighbour
            model.AddModelObject(coin_3, new Point(31, 31)); // should NOT be neighbour

            // Sizes:
            // -> biggest object: 10
            // -> current object: 10
            // So: currentPoint + currentObjectSize + biggestObjectSize = 30

            ICollection<ModelObject> neighbours = model.GetCloseModelObjects(player);

            Assert.AreEqual(3, neighbours.Count);

            foreach (var neigh in neighbours)
            {
                Assert.AreEqual(typeof(ModelCoin), neigh.GetType());
                Assert.AreNotEqual(coin_3, neigh);
            }
        }
Esempio n. 3
0
        public void HasSamePositionAt_Valid_Touched_Test()
        {
            VModel model = new VModel();

            Point size = new Point();
            size.X = 100;
            size.Y = 50;

            model.Map = new Map2d(size);

            // Insert a Wall exactly in the middle (vertical)
            model.Map.InsertWall(new Wall() { Start = new Point(50, 0), End = new Point(50, 50) });

            // Presume that the first id's are reserved for players
            ModelPlayer player = new ModelPlayer(model, 0, 10);

            // Create Coins
            ModelObject target = new ModelObject(model, 10, 2);

            // Add objects to model
            model.AddModelObject(target, new Point(10, 10));
            model.AddModelObject(player, new Point(10, 22)); // touches the coin

            bool result = target.hasSamePosition(player);

            Assert.AreEqual(true, result);
        }
Esempio n. 4
0
        public void PlayerMeetsCoin_Valid_Args_Test()
        {
            GameLogicMock target = new GameLogicMock();

            IVModel model = new VModel();

            // Create Objects
            ModelPlayer player = new ModelPlayer(model, 0, 10);
            ModelCoin coin = new ModelCoin(model, 10, 2);

            // Add Objects to model
            model.AddModelObject(player, new Point(10, 10));
            model.AddModelObject(coin, new Point(12, 12));

            var result = target.playerMeetsCoinAction(player, coin);

            Assert.AreEqual(1, target.CoinRemovedCounter);
        }
Esempio n. 5
0
        public void ComputePosition_Valid_Test()
        {
            GameLogicMock target = new GameLogicMock();

            IVModel model = new VModel();

            Point size = new Point();
            size.X = 100;
            size.Y = 50;

            model.Map = new Map2d(size);

            // Insert a Wall exactly in the middle
            model.Map.InsertWall(new Wall() { Start = new Point() { X = 0, Y = 25 }, End = new Point() { X = 100, Y = 25 } });

            Point toPosition = new Point(20, 10);

            // Create Objects
            ModelPlayer player = new ModelPlayer(model, 0, 10); // what is the size?
            ModelCoin coin = new ModelCoin(model, 10, 2);

            // Add Objects to model
            model.AddModelObject(player, new Point(10, 10));
            model.AddModelObject(coin, toPosition);

            bool result = target.computePosition(player, toPosition, true, true);

            Assert.AreEqual(true, result);
            Assert.AreEqual(1, target.CoinRemovedCounter);
        }