Пример #1
0
    public void ToString_Returns_Formatted_Subscription_Representation()
    {
        // Arrange
        var fixture          = new Fixture();
        var eventType        = fixture.Create <Type>();
        var eventHandlerType = fixture.Create <Type>();
        var subscription     = new EventSubscriptionInformation(eventHandlerType, eventType);

        // Act
        var result = subscription.ToString();

        // Assert
        result
        .Should()
        .Be($"[{eventType.Name}-{eventHandlerType.Name}]");
    }
Пример #2
0
    public void Properties_Return_Values_Passed_In_Constructor_During_Initialization()
    {
        // Arrange
        var fixture          = new Fixture();
        var eventType        = fixture.Create <Type>();
        var eventHandlerType = fixture.Create <Type>();

        // Act
        var subscription = new EventSubscriptionInformation(eventHandlerType, eventType);

        // Assert
        subscription
        .EventType
        .Should()
        .Be(eventType);

        subscription
        .EventHandlerType
        .Should()
        .Be(eventHandlerType);
    }
        /// <summary>
        /// Setup subscriptions for integration events and handlers under test and saves
        /// them in memento state, so they can be accessed later on.
        /// </summary>
        /// <returns></returns>
        public EventProcessingPipelineFixture SetupEventSubscriptions()
        {
            var subscription1 = new EventSubscriptionInformation(
                eventHandlerType: typeof(FakeEventHandler1),
                eventType: typeof(FakeIntegrationEvent));

            var subscription2 = new EventSubscriptionInformation(
                eventHandlerType: typeof(FakeEventHandler2),
                eventType: typeof(FakeIntegrationEvent));

            var eventSubscriptions = new[]
            {
                subscription1,
                subscription2,
            };

            Mock.Get(SubscriptionManager)
            .Setup(s => s
                   .HasSubscriptionsForEvent(It.IsAny <string>()))
            .Returns(true);

            Mock.Get(SubscriptionManager)
            .Setup(s => s
                   .GetEventTypeByName(It.IsAny <string>()))
            .Returns(typeof(FakeIntegrationEvent));

            Mock.Get(SubscriptionManager)
            .Setup(s => s
                   .GetHandlersForEvent(It.IsAny <string>()))
            .Returns(eventSubscriptions);

            Memento
            .Save(eventSubscriptions);

            return(this);
        }