public void ShouldFireAsynchronously()
        {
            var aggregator = new EventBus();
            aggregator.IsAsynchronous.ShouldBe(true);

            AsyncTest.Start(test =>
                        {
                            var args = new MyEvent();

                            aggregator.ShouldFireAsync<MyEvent>(
                                        () =>
                                            {
                                                aggregator.Publish(args);
                                            }, 
                                        e =>
                                            {
                                                e.ShouldBe(args);
                                                aggregator.IsAsynchronous.ShouldBe(true);
                                                test.Complete();
                                            });
                        });
        }
        public void ShouldRetainOriginalAsyncSetting()
        {
            var aggregator = new EventBus();

            aggregator.IsAsynchronous.ShouldBe(true);
            aggregator.ShouldFire<MyEvent>(() => aggregator.Publish(new MyEvent()));
            aggregator.IsAsynchronous.ShouldBe(true);

            aggregator.IsAsynchronous = false;
            aggregator.ShouldFire<MyEvent>(() => aggregator.Publish(new MyEvent()));
            aggregator.IsAsynchronous.ShouldBe(false);
        }
 public void ShouldFireTestMethod_SpecificNumberOfTimes_Fail()
 {
     var aggregator = new EventBus();
     Should.Throw<AssertionException>(() => aggregator.ShouldFire<MyEvent>(2, () =>
                 {
                     aggregator.Publish(new MyEvent());
                     aggregator.Publish(new MyEvent());
                     aggregator.Publish(new MyEvent());
                 }));
     Should.Throw<AssertionException>(() => aggregator.ShouldFire<MyEvent>(2, () => { }));
 }
 public void ShouldNotFireTestMethod()
 {
     var aggregator = new EventBus();
     aggregator.ShouldNotFire<MyEvent>(() => { });
     Should.Throw<AssertionException>(() => aggregator.ShouldNotFire<MyEvent>(() => aggregator.Publish(new MyEvent())));
 }
        public void ShouldFireTestMethod_SpecificNumberOfTimes()
        {
            var aggregator = new EventBus();
            aggregator.ShouldFire<MyEvent>(2, () =>
                    {
                        aggregator.Publish(new MyEvent());
                        aggregator.Publish(new MyEvent());
                    });

        }