示例#1
0
        public void HandleMultipleThrowingSubscriptions(
            Exception exception,
            SimpleEvent.EventPublisher publisher,
            ThrowingSubscriber subscriber1,
            ThrowingSubscriber subscriber2)
        {
            "Establish a registered publisher and throwing subscriber".x(() =>
            {
                publisher   = new SimpleEvent.EventPublisher();
                subscriber1 = new ThrowingSubscriber();
                subscriber2 = new ThrowingSubscriber();

                this.eventBroker.Register(publisher);
                this.eventBroker.Register(subscriber1);
                this.eventBroker.Register(subscriber2);
            });

            "When firing an event".x(() =>
                                     exception = Catch.Exception(() => publisher.FireEvent(EventArgs.Empty)));

            "It should pass the exception to the publisher".x(() =>
                                                              exception
                                                              .Should().NotBeNull()
                                                              .And.Subject.As <Exception>().Message
                                                              .Should().Be("test"));

            "It should stop executing subscribers after the first exception".x(() =>
                                                                               subscriber2.Handled.Should().BeFalse("second subscriber should not be clled anymore"));
        }
示例#2
0
        public void HandleThrowingSubscriptionWithExtension(
            Exception exception,
            SimpleEvent.EventPublisher publisher,
            ThrowingSubscriber subscriber)
        {
            "Establish a registered publisher and throwing subscriber".x(() =>
            {
                publisher  = new SimpleEvent.EventPublisher();
                subscriber = new ThrowingSubscriber();

                this.eventBroker.Register(publisher);
                this.eventBroker.Register(subscriber);

                this.eventBroker.AddExtension(new ExceptionHandlingExtension());
            });

            "When firing an event".x(() =>
                                     exception = Catch.Exception(() => publisher.FireEvent(EventArgs.Empty)));

            "It should not pass exception to the publisher".x(() =>
                                                              exception
                                                              .Should().BeNull());
        }
示例#3
0
        public void HandleThrowingSubscription(
            Exception exception,
            SimpleEvent.EventPublisher publisher,
            ThrowingSubscriber subscriber)
        {
            "Establish a registered publisher and throwing subscriber".x(() =>
            {
                publisher  = new SimpleEvent.EventPublisher();
                subscriber = new ThrowingSubscriber();

                this.eventBroker.Register(publisher);
                this.eventBroker.Register(subscriber);
            });

            "When firing an event".x(() =>
                                     exception = Catch.Exception(() => publisher.FireEvent(EventArgs.Empty)));

            "It should pass the exception to the publisher".x(() =>
                                                              exception
                                                              .Should().NotBeNull()
                                                              .And.Subject.As <Exception>().Message
                                                              .Should().Be("test"));
        }