Exemplo n.º 1
0
        public void throws_expected_exception_when_no_topic_is_registered_for_an_event_type()
        {
            var stubEventTypeName = "foo";
            var sut = new DomainEventRegistryBuilder().Build();

            Assert.Throws <MessagingException>(() => sut.GetTopicFor(stubEventTypeName));
        }
Exemplo n.º 2
0
        public void returns_expected_registrations_when_registering_multiple_events()
        {
            var stubRegistration1 = new DomainEventRegistrationBuilder()
                                    .WithEventInstanceType <FooDomainEvent>()
                                    .WithEventType("foo-event-type")
                                    .WithTopic("foo-topic")
                                    .Build();

            var stubRegistration2 = new DomainEventRegistrationBuilder()
                                    .WithEventInstanceType <BarDomainEvent>()
                                    .WithEventType("bar-event-type")
                                    .WithTopic("bar-topic")
                                    .Build();

            var sut = new DomainEventRegistryBuilder().Build();

            sut.Register <FooDomainEvent>(stubRegistration1.EventType, stubRegistration1.Topic);
            sut.Register <BarDomainEvent>(stubRegistration2.EventType, stubRegistration2.Topic);

            Assert.Equal(
                expected: new[] { stubRegistration1, stubRegistration2 },
                actual: sut.Registrations,
                comparer: new PropertiesComparer <DomainEventRegistration>()
                );
        }
Exemplo n.º 3
0
        public void throws_expected_exception_when_no_event_type_name_is_registered_for_an_event_instance()
        {
            var stubEvent = new FooDomainEvent();
            var sut       = new DomainEventRegistryBuilder().Build();

            Assert.Throws <MessagingException>(() => sut.GetTypeNameFor(stubEvent));
        }
Exemplo n.º 4
0
        public void throws_expected_exception_when_no_instance_type_is_registered(string eventName)
        {
            var stubEvent        = new FooDomainEvent();
            var stubRegistration = new DomainEventRegistrationBuilder()
                                   .WithEventInstanceType(stubEvent)
                                   .Build();

            var sut = new DomainEventRegistryBuilder().Build();

            sut.Register <FooDomainEvent>(stubRegistration.EventType, stubRegistration.Topic);

            Assert.Throws <MessagingHandlerNotAvailable>(() => sut.GetInstanceTypeFor(eventName));
        }
Exemplo n.º 5
0
        public void returns_expected_instance_type()
        {
            var stubEvent        = new FooDomainEvent();
            var stubRegistration = new DomainEventRegistrationBuilder()
                                   .WithEventInstanceType(stubEvent)
                                   .Build();

            var sut = new DomainEventRegistryBuilder().Build();

            sut.Register <FooDomainEvent>(stubRegistration.EventType, stubRegistration.Topic);

            var result = sut.GetInstanceTypeFor(stubRegistration.EventType);

            Assert.Equal(typeof(FooDomainEvent), result);
        }
Exemplo n.º 6
0
        public void returns_expected_registrations_when_registering_single_event()
        {
            var stubRegistration = new DomainEventRegistrationBuilder()
                                   .WithEventInstanceType <FooDomainEvent>()
                                   .Build();

            var sut = new DomainEventRegistryBuilder().Build();

            sut.Register <FooDomainEvent>(stubRegistration.EventType, stubRegistration.Topic);

            Assert.Equal(
                expected: new[] { stubRegistration },
                actual: sut.Registrations,
                comparer: new PropertiesComparer <DomainEventRegistration>()
                );
        }
Exemplo n.º 7
0
        public void returns_expected_topic()
        {
            var stubRegistration = new DomainEventRegistrationBuilder()
                                   .WithEventInstanceType <FooDomainEvent>()
                                   .Build();

            var sut = new DomainEventRegistryBuilder().Build();

            sut.Register <FooDomainEvent>(stubRegistration.EventType, stubRegistration.Topic);

            var result = sut.GetTopicFor(stubRegistration.EventType);

            Assert.Equal(
                expected: stubRegistration.Topic,
                actual: result
                );
        }
Exemplo n.º 8
0
        public void returns_expected_event_type_name()
        {
            var stubEvent = new FooDomainEvent();

            var stubRegistration = new DomainEventRegistrationBuilder()
                                   .WithEventInstanceType(stubEvent)
                                   .Build();

            var sut = new DomainEventRegistryBuilder().Build();

            sut.Register <FooDomainEvent>(stubRegistration.EventType, stubRegistration.Topic);

            var result = sut.GetTypeNameFor(stubEvent);

            Assert.Equal(
                expected: stubRegistration.EventType,
                actual: result
                );
        }
Exemplo n.º 9
0
        public void returns_expected_registrations_when_initialized()
        {
            var sut = new DomainEventRegistryBuilder().Build();

            Assert.Empty(sut.Registrations);
        }