public void GivenTorpedo_WhenProcessTick_ThenTorpedoMoves() { SetupFakeWorld(true, false); var bot = FakeGameObjectProvider.GetBotWithActions(); bot.CurrentHeading = 90; bot.Speed = 20; bot.IsMoving = true; var torpedoPosition = VectorCalculatorService.GetPositionFrom(bot.Position, bot.Size + EngineConfigFake.Value.Torpedo.Size + 1, bot.CurrentAction.Heading); var torpedoSalvo = new TorpedoGameObject() { Id = Guid.NewGuid(), Position = torpedoPosition, Size = EngineConfigFake.Value.Torpedo.Size, Speed = EngineConfigFake.Value.Torpedo.Speed, CurrentHeading = 45, FiringPlayerId = bot.Id, IsMoving = true }; WorldStateService.AddGameObject(torpedoSalvo); tickProcessingService = new TickProcessingService( collisionHandlerResolver, VectorCalculatorService, WorldStateService, collisionService); Assert.DoesNotThrow(() => tickProcessingService.SimulateTick()); Assert.AreNotEqual(torpedoPosition, torpedoSalvo.Position); }
public void GivenBot_WhenActionIsProcessed_ThenVectorIsStepwiseCalculated() { SetupFakeWorld(true, false); var bot = FakeGameObjectProvider.GetBotWithActions(); bot.IsMoving = true; vectorCalculatorServiceMock.Setup(x => x.GetPointFrom(It.IsAny <Position>(), It.IsAny <int>(), It.IsAny <int>())) .Returns(VectorCalculatorService.GetPointFrom(bot.Position, 1, bot.CurrentHeading)); vectorCalculatorServiceMock.Setup(x => x.IsInWorldBounds(It.IsAny <Position>(), It.IsAny <int>())).Returns(true); vectorCalculatorServiceMock .Setup(vcs => vcs.CollectCollisionDetectionPointsAlongPath(It.IsAny <Position>(), It.IsAny <Position>(), It.IsAny <int>())) .Returns( new List <Position> { new Position(0, 0), new Position(1, 1), new Position(2, 2) }); Assert.DoesNotThrow(() => tickProcessingService.SimulateTick()); }
public void GivenBot_WhenSizeChangesDuringActionProcessing_ThenRemainingProcessStepsAreAdjusted() { SetupFakeWorld(true, false); var food = PlaceFoodAtPosition(new Position(0, 1)); var bot = FakeGameObjectProvider.GetBotWithActions(); bot.CurrentHeading = 90; bot.Speed = 20; bot.IsMoving = true; tickProcessingService = new TickProcessingService( collisionHandlerResolver, VectorCalculatorService, WorldStateService, collisionService); Assert.DoesNotThrow(() => tickProcessingService.SimulateTick()); Assert.AreEqual(11, bot.Size); Assert.AreEqual(19, bot.Speed); Assert.AreEqual(new Position(0, 19), bot.Position); }