public void ExecuteGameLoop_when_paused_only_calls_certain_components()
        {
            _keyboardHandler.IsNewlyPressed(Keys.Space).Returns(true);

            var actionHandler = new ActionHandler(_keyboardHandler);
            _gameEngine = new GameEngine(_universe, _gravitySimulator, _gameObjectFactory, _keyboardHandler, actionHandler, _drawingManager);

            _gameEngine.ExecuteGameLoop(new GameTime());

            _keyboardHandler.Received(1).UpdateKeyboardState();

            _gameObjectFactory.DidNotReceive().DestroyAll(Arg.Any<Predicate<IGameObject>>());
            _gravitySimulator.DidNotReceive().Simulate();
            _universe.DidNotReceive().Update();
            var temp = _gameObjectFactory.DidNotReceive().GameObjects;
            Assert.IsNull(temp);
        }
Example #2
0
        internal SpaceWar2Game()
        {
            _contentManager = new ContentManagerWrapper(Content.ServiceProvider, "Content");
            var graphicsDeviceManager = new GraphicsDeviceManager(this);
            _graphicsDevice = new GraphicsDeviceWrapper(graphicsDeviceManager);

            _universe = Universe.CreateDefault();
            _drawingManager = new DrawingManager(_universe);
            _gravitySimulator = new GravitySimulator();
            _shipComponentFactory = new ShipComponentFactory();
            _graphicsFactory = new GraphicsFactory();

            _gameObjectFactory = new GameObjectFactory(_contentManager, _graphicsFactory, _gravitySimulator, _drawingManager, _universe, _shipComponentFactory);

            _keyboardHandler = new KeyboardHandler(new KeyboardWrapper());

            var actionHandler = new ActionHandler(_keyboardHandler);

            _gameEngine = new GameEngine(_universe, _gravitySimulator, _gameObjectFactory, _keyboardHandler, actionHandler, _drawingManager);

            SetUpActions(actionHandler);
        }
        public void SetUp()
        {
            _universe = Substitute.For<IUniverse>();
            _gravitySimulator = Substitute.For<IGravitySimulator>();
            _gameObjectFactory = Substitute.For<IGameObjectFactory>();
            _keyboardHandler = Substitute.For<IKeyboardHandler>();
            _actionHandler = Substitute.For<IActionHandler>();
            _drawingManager = Substitute.For<IDrawingManager>();

            _gameEngine = new GameEngine(_universe, _gravitySimulator, _gameObjectFactory, _keyboardHandler, _actionHandler, _drawingManager);
        }