예제 #1
0
        public void GetInstanceTypeFor_given_non_registered_event_throws_expected_exception()
        {
            // Arrange
            var topic         = "build.capabilities";
            var eventTypeName = "dummyEventName";

            var sut = new DomainEventRegistry()
                      .Register <CapabilityCreatedDomainEvent>(
                eventName: "capability_created",
                topicName: topic)
                      .Register <MemberJoinedCapabilityDomainEvent>(
                eventName: "member_joined_capability",
                topicName: topic)
                      .Register <MemberLeftCapabilityDomainEvent>(
                eventName: "member_left_capability",
                topicName: topic);

            // Act and assert
            Exception ex = Assert.Throws <EventTypeNotFoundException>(() => sut.GetInstanceTypeFor(eventTypeName));

            Assert.Contains("Error! Could not determine \"event instance type\"", ex.Message);
        }
예제 #2
0
        public void GetInstanceTypeFor_given_registered_event_returns_expected_type()
        {
            // Arrange
            var topic         = "build.capabilities";
            var eventTypeName = "capability_created";

            var sut = new DomainEventRegistry()
                      .Register <CapabilityCreatedDomainEvent>(
                eventName: eventTypeName,
                topicName: topic)
                      .Register <MemberJoinedCapabilityDomainEvent>(
                eventName: "member_joined_capability",
                topicName: topic)
                      .Register <MemberLeftCapabilityDomainEvent>(
                eventName: "member_left_capability",
                topicName: topic);

            // Act
            var type = sut.GetInstanceTypeFor(eventTypeName);

            // Assert
            Assert.Equal(typeof(CapabilityCreatedDomainEvent), type);
        }