Beispiel #1
0
        public void TestOldConfigPersists()
        {
            using (var host = new TestHeadlessGameHost(bypassCleanup: true))
            {
                host.Run(new TestGame((h, config) =>
                {
                    storage = h.Storage;
#pragma warning disable 618
                    config.SetValue(FrameworkSetting.CursorSensitivity, 5.0);
#pragma warning restore 618
                }));
            }

            // test with only FrameworkConfigManager configuration file present
            storage.Delete(InputConfigManager.FILENAME);

            double sensitivity = 0;

            using (var host = new TestHeadlessGameHost())
            {
                host.Run(new TestGame((h, config) => sensitivity = h.AvailableInputHandlers.OfType <MouseHandler>().First().Sensitivity.Value));
            }

            Assert.AreEqual(5, sensitivity);
        }
 public void IsAliveTest()
 {
     using (var client = new TestHeadlessGameHost(@"client", true))
     {
         var testGame = new TestTestGame();
         client.Run(testGame);
         Assert.IsTrue(testGame.IsRootAlive);
     }
 }
        public void TestPauseResume()
        {
            var gameCreated = new ManualResetEventSlim();

            var task = Task.Run(() =>
            {
                using (host = new TestHeadlessGameHost(@"host", false))
                {
                    game = new TestTestGame();
                    gameCreated.Set();
                    host.Run(game);
                }
            });

            Assert.IsTrue(gameCreated.Wait(timeout));
            Assert.IsTrue(game.BecameAlive.Wait(timeout));

            // check scheduling is working before suspend
            var completed = new ManualResetEventSlim();

            game.Schedule(() => completed.Set());
            Assert.IsTrue(completed.Wait(timeout / 10));

            host.Suspend();

            completed.Reset();

            // check that scheduler doesn't process while suspended..
            game.Schedule(() => completed.Set());
            Assert.IsFalse(completed.Wait(timeout / 10));

            host.Resume();

            // ..and does after resume.
            Assert.IsTrue(completed.Wait(timeout / 10));

            game.Exit();

            Assert.IsTrue(task.Wait(timeout));
        }
Beispiel #4
0
        public void TestNewConfigPersists()
        {
            using (var host = new TestHeadlessGameHost(bypassCleanup: true))
            {
                host.Run(new TestGame((h, config) =>
                {
                    storage = h.Storage;
                    h.AvailableInputHandlers.OfType <MouseHandler>().First().Sensitivity.Value = 5;
                }));
            }

            // test with only InputConfigManager configuration file present
            storage.Delete(FrameworkConfigManager.FILENAME);

            double sensitivity = 0;

            using (var host = new TestHeadlessGameHost())
            {
                host.Run(new TestGame((h, config) => sensitivity = h.AvailableInputHandlers.OfType <MouseHandler>().First().Sensitivity.Value));
            }

            Assert.AreEqual(5, sensitivity);
        }