public void TestMoveDown() { var tankEngine = new TankEngine(); var map = new MapBase { GameMap = new int[100, 100], Borders = new List <int> { 0, 0, 100, 100 } }; int tankInitX = 5, tankInitY = 10; var tank = new List <TankFragment>(); var gameMap = new int[100, 100]; tankEngine.TankInit(out tank, tankInitX, tankInitY, MoveDirection.Right, gameMap); var testList = new List <TankFragment>(tank.Count); testList.AddRange(tank.Select(t => new TankFragment(t.X, t.Y))); tankEngine.TankMove(tank, MoveDirection.Down, map); Assert.IsTrue(testList[0].Y + 1 == tank[0].Y && testList[1].Y + 1 == tank[1].Y && testList[2].Y + 1 == tank[2].Y && testList[3].Y + 1 == tank[3].Y && testList[4].Y + 1 == tank[4].Y && testList[5].Y + 1 == tank[5].Y && testList[6].Y + 1 == tank[6].Y && testList[7].Y + 1 == tank[7].Y && testList[8].Y + 1 == tank[8].Y); }
public void TestMoveUp() { var tankEngine = new TankEngine(); var map = new MapBase(); map.GameMap = new int[100, 100]; map.Borders = new List <int> { 0, 0, 100, 100 }; int tankInitX = 5, tankInitY = 10; var tank = new List <TankFragment>(); var gameMap = new int[100, 100]; tankEngine.TankInit(out tank, tankInitX, tankInitY, MoveDirection.Right, gameMap); var testList = new List <TankFragment>(tank.Count); foreach (TankFragment t in tank) { var item = new TankFragment(t.X, t.Y); testList.Add(item); } tankEngine.TankMove(tank, MoveDirection.Up, map); Assert.IsTrue(testList[0].Y - 1 == tank[0].Y && testList[1].Y - 1 == tank[1].Y && testList[2].Y - 1 == tank[2].Y && testList[3].Y - 1 == tank[3].Y && testList[4].Y - 1 == tank[4].Y && testList[5].Y - 1 == tank[5].Y && testList[6].Y - 1 == tank[6].Y && testList[7].Y - 1 == tank[7].Y && testList[8].Y - 1 == tank[8].Y); }