public void SetUp()
        {
            this.testee = new EventBroker();

            this.publisher = new NamedPublisher("Test.One");
            this.subscriberParent = new NamedSubscriber("Test");
            this.subscriberTwin = new NamedSubscriber("Test.One");
            this.subscriberSibling = new NamedSubscriber("Test.Two");
            this.subscriberChild = new NamedSubscriber("Test.One.Child");

            this.testee.Register(this.publisher);
            this.testee.Register(this.subscriberParent);
            this.testee.Register(this.subscriberTwin);
            this.testee.Register(this.subscriberSibling);
            this.testee.Register(this.subscriberChild);
        }
        public void SetUp()
        {
            this.testee = new EventBroker();

            this.publisher         = new NamedPublisher("Test.One");
            this.subscriberParent  = new NamedSubscriber("Test");
            this.subscriberTwin    = new NamedSubscriber("Test.One");
            this.subscriberSibling = new NamedSubscriber("Test.Two");
            this.subscriberChild   = new NamedSubscriber("Test.One.Child");

            this.testee.Register(this.publisher);
            this.testee.Register(this.subscriberParent);
            this.testee.Register(this.subscriberTwin);
            this.testee.Register(this.subscriberSibling);
            this.testee.Register(this.subscriberChild);
        }
Example #3
0
        public void Describe(
            EventBroker eventBroker,
            StringWriter writer,
            string description,
            Publisher publisher,
            NamedPublisher namedPublisher,
            Subscriber subscriber,
            NamedSubscriber namedSubscriber)
        {
            "Establish an event broker with publisher and subscriber".x(() =>
            {
                eventBroker = new EventBroker();

                publisher       = new Publisher();
                namedPublisher  = new NamedPublisher();
                subscriber      = new Subscriber();
                namedSubscriber = new NamedSubscriber();

                eventBroker.Register(publisher);
                eventBroker.Register(namedPublisher);
                eventBroker.Register(subscriber);
                eventBroker.Register(namedSubscriber);
            });

            "Establish a string writer".x(() =>
                                          writer = new StringWriter());

            "When writing description to".x(() =>
            {
                eventBroker.DescribeTo(writer);
                description = writer.ToString();
            });

            "It should lists all event topics".x(() =>
                                                 description
                                                 .Should().Contain(SimpleEventTopic)
                                                 .And.Contain(CustomEventTopic));

            "it should lists all publishers per event topics".x(() =>
                                                                description
                                                                .Should().Match("*" + SimpleEventTopic + "*" + typeof(Publisher) + "*" + CustomEventTopic + "*")
                                                                .And.Match("*" + SimpleEventTopic + "*" + typeof(NamedPublisher) + "*" + CustomEventTopic + "*")
                                                                .And.Match("*" + CustomEventTopic + "*" + typeof(Publisher) + "*"));

            "It should lists all subscribers per event topic".x(() =>
                                                                description
                                                                .Should().Match("*" + SimpleEventTopic + "*" + typeof(Subscriber) + "*" + CustomEventTopic + "*")
                                                                .And.Match("*" + CustomEventTopic + "*" + typeof(NamedSubscriber) + "*"));

            "It should list the event name per publisher".x(() =>
                                                            description
                                                            .Should().Match(
                                                                "*" +
                                                                typeof(Publisher) +
                                                                "*Event = SimpleEvent*" +
                                                                typeof(NamedPublisher) +
                                                                "*Event = SimpleEvent*" +
                                                                typeof(Publisher) +
                                                                "*Event = CustomEvent*"));

            "It should list event handler type per publisher".x(() =>
                                                                description
                                                                .Should().Match(
                                                                    "*" +
                                                                    typeof(Publisher) +
                                                                    "*EventHandler type = System.EventHandler*" +
                                                                    typeof(NamedPublisher) +
                                                                    "*EventHandler type = System.EventHandler*" +
                                                                    typeof(Publisher) +
                                                                    "*EventHandler type = System.EventHandler<Appccelerate.EventBroker.Description.DescribeToSpecifications+CustomEventArgs>*"));

            "It should list matchers per publisher and subscriber".x(() =>
                                                                     description
                                                                     .Should().Match(
                                                                         "*" +
                                                                         typeof(NamedPublisher) +
                                                                         "*matchers = subscriber name starts with publisher name*" +
                                                                         typeof(Subscriber) +
                                                                         "*matchers = always*"));

            "It should list the name of named publishers and subscribers".x(() =>
                                                                            description
                                                                            .Should().Match(
                                                                                "*" +
                                                                                typeof(NamedPublisher) +
                                                                                "*Name = NamedCustomEventPublisherName*" +
                                                                                typeof(NamedSubscriber) +
                                                                                "*Name = NamedSubscriberName*"));

            "And it lists handler method per subscriber".x(() => description
                                                           .Should().Match(
                                                               "*" +
                                                               typeof(Subscriber) +
                                                               "*Handler method = HandleSimpleEvent*" +
                                                               typeof(NamedSubscriber) +
                                                               "*Handler method = HandleCustomEvent*"));

            "And it lists handler type per subscriber".x(() => description
                                                         .Should().Match(
                                                             "*" +
                                                             typeof(Subscriber) +
                                                             "*Handler = Appccelerate.EventBroker.Handlers.OnPublisher*" +
                                                             typeof(NamedSubscriber) +
                                                             "*Handler = Appccelerate.EventBroker.Handlers.OnPublisher*"));

            "And it lists event args type per subscriber".x(() => description
                                                            .Should().Match(
                                                                "*" +
                                                                typeof(Subscriber) +
                                                                "*EventArgs type = System.EventArgs*" +
                                                                typeof(NamedSubscriber) +
                                                                "*EventArgs type = Appccelerate.EventBroker.Description.DescribeToSpecifications+CustomEventArgs, *"));
        }