Example #1
0
        public void UpdateCalledOnEnabledIUpdatableGameComponent()
        {
            TestGame game = new TestGame(new NullEventSource());

            GameComponentTestBase gc = new GameComponentTestBase(game);

            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(1, gc.CountUpdate);
        }
Example #2
0
        public void InitializeCalledOnIGameComponentTest()
        {
            TestGame game = new TestGame(new NullEventSource());

            GameComponentTestBase gc = new GameComponentTestBase(game);

            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(1, gc.CountInitialize);
        }
Example #3
0
        public void UpdateCalledOnceForIUpdatableGameComponent()
        {
            DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e)
            {
                GameComponentTestBase u = (GameComponentTestBase)e.Game.Components[0];
                u.Enabled = false;
                for (int i = 0; i < 5; i++)
                {
                    TestClock.Instance.Step(100);
                    e.Game.Tick();
                }
            });
            TestGame game            = new TestGame(evt);
            GameComponentTestBase gc = new GameComponentTestBase(game);

            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(1, gc.CountUpdate);
        }
Example #4
0
        public void UpdateCalledOnceForIUpdatableGameComponent()
        {
            DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e)
                                                                            {
                                                                                GameComponentTestBase u = (GameComponentTestBase)e.Game.Components[0];
                                                                                u.Enabled = false;
                                                                                for (int i = 0; i < 5; i++)
                                                                                {
                                                                                    TestClock.Instance.Step(100);
                                                                                    e.Game.Tick();
                                                                                }
                                                                            });
            TestGame game = new TestGame(evt);
            GameComponentTestBase gc = new GameComponentTestBase(game);
            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(1, gc.CountUpdate);
        }
Example #5
0
        public void UpdateNotCalledOnDisabledIUpdatableGameComponent()
        {
            TestGame game = new TestGame(new NullEventSource());

            GameComponentTestBase gc = new GameComponentTestBase(game);
            game.Components.Add(gc);
            gc.Enabled = false;

            game.Run();

            Assert.AreEqual(0, gc.CountUpdate);
        }
Example #6
0
        public void InitializeCalledOnIGameComponentTest()
        {
            TestGame game = new TestGame(new NullEventSource());

            GameComponentTestBase gc = new GameComponentTestBase(game);
            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(1, gc.CountInitialize);
        }