Ejemplo n.º 1
0
        public void WhenCoordinateIsNotWithinCoordinateRange_ReturnFalse()
        {
            var coords1 = TestMocksFactory.GetCellCoordinates(3, 3);
            var coords2 = TestMocksFactory.GetCellCoordinates(2, 2);
            var range   = 1;

            var isWithinRange = coords1.AreCoordinatesInRange(coords2, range);

            Assert.IsFalse(isWithinRange);
        }
Ejemplo n.º 2
0
        public void WhenCoordinateIsWithinCoordinateRange_ReturnTrue()
        {
            var coords1 = TestMocksFactory.GetCellCoordinates(0, 0);
            var coords2 = TestMocksFactory.GetCellCoordinates(2, 0);
            var range   = 2;

            var isWithinRange = coords1.AreCoordinatesInRange(coords2, range);

            Assert.IsTrue(isWithinRange);
        }
Ejemplo n.º 3
0
        public void WhenDamageIsApplied_DamageIsSubstractedFromHealthOk()
        {
            var unitStats = new UnitStatsConfigBuilder().WithHealthPoints(100).Build();
            var unit      = new TestUnitBuilder().WithStats(unitStats).Build();

            var unitHealth        = TestMocksFactory.GetMockUnitHealth(unit);
            var damage            = 1;
            var damageUnitCommand = new DamageUnitCommand(unitHealth, damage);

            var expectedHealth = unit.HealthPoints.Current - damage;

            damageUnitCommand.Execute();

            Assert.AreEqual(unit.HealthPoints.Current, expectedHealth);
        }
Ejemplo n.º 4
0
        public void WhenAnUnitIsOnACell_AndAskingIfTheCellIsFree_ReturnFalse()
        {
            var grid          = TestMocksFactory.GetMockGrid();
            var unitSpawnCell = TestMocksFactory.GetMockCell(
                0,
                TestMocksFactory.GetCellCoordinates(0, 0),
                new int[0]
                );
            var unitController = TestMocksFactory.GetMockCharacterController(unitSpawnCell, grid);

            grid.AddCharacter(unitController);

            var isCellFree = grid.IsCellFree(unitController.GetCurrentCellId());

            Assert.IsFalse(isCellFree);
        }
Ejemplo n.º 5
0
        public void WhenAskingForAdjacentCellsOfCell_ReturnCorrectAdjacentCells()
        {
            var grid = TestMocksFactory.GetMockGrid();
            var cell = grid.GetCellById(5);

            var adjacentCellIds = cell.GetAdjacentCellsIds();

            var expectedAdjacentCellIds = new int[4]
            {
                cell.Id + grid.Columns,
                cell.Id + 1,
                cell.Id - grid.Columns,
                cell.Id - 1
            };
            var expectedAdjacentCellIdsClean = expectedAdjacentCellIds.Where(cellId => cellId > -1).ToArray();

            Assert.AreEqual(adjacentCellIds, expectedAdjacentCellIdsClean);
        }
Ejemplo n.º 6
0
        public void WhenAskingForExistingCell_ReturnAskedCell()
        {
            var grid = TestMocksFactory.GetMockGrid();

            var expectedCellId = 1;
            var cell           = grid.GetCellById(expectedCellId);

            var expectedX    = 1;
            var expectedY    = 0;
            var expectedCell = new Cell(
                expectedCellId,
                new CellCoordinates(expectedX, expectedY),
                new Vector2(1, 0),
                null
                );

            Assert.AreEqual(cell.Id, expectedCell.Id);
            Assert.AreEqual(cell.Coordinates, expectedCell.Coordinates);
        }
Ejemplo n.º 7
0
        public void WhenAskingForUnexistingCell_ReturnNull()
        {
            var grid = TestMocksFactory.GetMockGrid();

            Assert.IsNull(grid.GetCellById(-1));
        }
Ejemplo n.º 8
0
        public void WhenACellIsFree_AndAskingIfItsFree_ReturnTrue()
        {
            var grid = TestMocksFactory.GetMockGrid();

            Assert.IsTrue(grid.IsCellFree(0));
        }