public void test_can_create_and_run_command_group()
        {
            Registry.Default.Reset();
            Registry.Default.Register <UtilityCommandHandler>();
            Registry.Default.Register <IServiceRegistry, ServiceRegistry>(Registry.Default);

            var subs      = 0;
            var completed = false;

            var seq = new ExecuteSequenceCommand();

            seq.Add(new DelegateCommand(() =>
            {
                subs += 5;
                Assert(!completed);
            })).Add(new DelegateCommand(() =>
            {
                subs += 5;
                Assert(!completed);
            }));

            seq.OnCompleted(ep => { completed = true; });
            seq.Execute(Registry.Default);

            Assert(completed);
            Assert(subs == 10);
        }
Beispiel #2
0
        public void test_can_create_and_run_commands()
        {
            Registry.Default.Reset();
            Registry.Default.Register <UtilityCommandHandler>();
            Registry.Default.Register <IServiceRegistry, ServiceRegistry>(Registry.Default);

            EventManager.Instance.Clear(true);
            EventStream.Default.Dispose();

            var subs      = 0;
            var completed = false;

            var seq = new ExecuteSequenceCommand();

            seq.Add(new ExecuteDeferredCommand()
            {
                Command = new DelegateCommand(() =>
                {
                    subs += 5;
                    Assert(!completed);
                }),
                Delay = 1f
            });

            seq.Add(new ExecuteDeferredCommand()
            {
                Command = new DelegateCommand(() =>
                {
                    subs += 10;
                    Assert(!completed);
                }),
                Delay = 1f
            });

            seq.OnCompleted(ep => { completed = true; });
            seq.Execute(Registry.Default);

            EventManager.Instance.Update(1f);
            EventManager.Instance.Update(1f);

            Assert(completed);
            Assert(subs == 15);

            EventManager.Instance.Clear(true);
        }