示例#1
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));
        }
        public void Invoking_it_a_type_that_is_the_same_as_the_TEventType_should_invoke_the_handle_event_method()
        {
            var theHandler = MockRepository.GenerateMock<SourcedEventHander<FooDomainEvent>>();
            var theFooEvent = new FooDomainEvent();

            var handlerAsIDomainEventHandler = theHandler as ISourcedEventHandler;
            handlerAsIDomainEventHandler.HandleEvent(theFooEvent);

            theHandler.AssertWasCalled(h => h.HandleEvent(theFooEvent));
        }
示例#3
0
        public void Invoking_it_a_type_that_is_the_same_as_the_TEventType_should_invoke_the_handle_event_method()
        {
            var theHandler  = MockRepository.GenerateMock <SourcedEventHander <FooDomainEvent> >();
            var theFooEvent = new FooDomainEvent();

            var handlerAsIDomainEventHandler = theHandler as ISourcedEventHandler;

            handlerAsIDomainEventHandler.HandleEvent(theFooEvent);

            theHandler.AssertWasCalled(h => h.HandleEvent(theFooEvent));
        }
示例#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));
        }
示例#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);
        }
示例#6
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
                );
        }