Exemplo n.º 1
0
        public void ShouldExecuteSynchro()
        {
            var factory = new UnitOfExecutionsFactory();
            var synchronousUnitOfExec = factory.GetSynchronousUnitOfExecution();
            var synchro = new object();

            lock (synchro)
            {
                synchronousUnitOfExec.Dispatch(
                    () =>
                {
                    Check.That(Monitor.TryEnter(synchro)).IsTrue();
                    Monitor.Exit(synchro);
                });
            }
        }
Exemplo n.º 2
0
        public void Should_Be_Fast()
        {
            var factory    = new UnitOfExecutionsFactory();
            var unitOfExec = factory.GetSynchronousUnitOfExecution();
            var sequencer  = this.BuildSequencer(unitOfExec);

            var    chrono = new Stopwatch();
            Action action = () => { };

            Check.ThatCode(() =>
            {
                for (var i = 0; i < 100000; i++)
                {
                    sequencer.Dispatch(action);
                }
            }).LastsLessThan(400, TimeUnit.Milliseconds);
        }