Beispiel #1
0
        public void DrawCalledOnVisibleIDrawableGameComponent()
        {
            DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { e.Game.Tick(); });
            TestGame game = new TestGame(evt);

            ((TestGameWindow)game.Window).RaiseVisibleChanged(true);

            DrawableGameComponentTestBase gc = new DrawableGameComponentTestBase(game);

            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(1, gc.CountDraw);
        }
Beispiel #2
0
        public void DrawCalledWhenIDrawableGameComponentIsVisibleTest()
        {
            DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e)
            {
                DrawableGameComponentTestBase u = (DrawableGameComponentTestBase)e.Game.Components[0];
                for (int i = 1; i < 6; i++)
                {
                    TestClock.Instance.Step(100);
                    e.Game.Tick();
                    u.Visible = i % 2 == 0;
                }
            });
            TestGame game = new TestGame(evt);

            ((TestGameWindow)game.Window).RaiseVisibleChanged(true);
            DrawableGameComponentTestBase gc = new DrawableGameComponentTestBase(game);

            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(3, gc.CountDraw, "Unexpected draw count");
            Assert.AreEqual(6, gc.CountUpdate, "Unexpected update count");
        }
Beispiel #3
0
        public void DrawCalledWhenIDrawableGameComponentIsVisibleTest()
        {
            DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e)
                                                                            {
                                                                                DrawableGameComponentTestBase u = (DrawableGameComponentTestBase)e.Game.Components[0];
                                                                                for (int i = 1; i < 6; i++)
                                                                                {
                                                                                    TestClock.Instance.Step(100);
                                                                                    e.Game.Tick();
                                                                                    u.Visible = i%2 == 0;
                                                                                }
                                                                            });
            TestGame game = new TestGame(evt);
            ((TestGameWindow)game.Window).RaiseVisibleChanged(true);
            DrawableGameComponentTestBase gc = new DrawableGameComponentTestBase(game);
            game.Components.Add(gc);

            game.Run();

            Assert.AreEqual(3, gc.CountDraw, "Unexpected draw count");
            Assert.AreEqual(6, gc.CountUpdate, "Unexpected update count");
        }
Beispiel #4
0
        public void DrawNotCalledOnNonVisibleIDrawableGameComponent()
        {
            DelegateBasedEventSource evt = new DelegateBasedEventSource(delegate(DelegateBasedEventSource e) { e.Game.Tick(); });
            TestGame game = new TestGame(evt);
            ((TestGameWindow)game.Window).RaiseVisibleChanged(true);

            DrawableGameComponentTestBase gc = new DrawableGameComponentTestBase(game);
            game.Components.Add(gc);
            gc.Visible = false;

            game.Run();

            Assert.AreEqual(0, gc.CountDraw);
        }