Example #1
0
            public void ReturnFalseIfSagaCannotStartWithEventType()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanHandle((FakeHandledEvent e) => e.Id);

                Assert.False(configuration.GetMetadata().CanHandle(typeof(FakeUnhandledEvent)));
            }
            public void EventMarkedAsInitiatingEvent()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanStartWith((FakeEvent e) => e.Id);

                Assert.True(configuration.GetMetadata().CanStartWith(typeof(FakeEvent)));
            }
Example #3
0
            public void ReturnTrueIfSagaCanStartWithEventType()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanStartWith((FakeInitiatingEvent e) => e.Id);

                Assert.True(configuration.GetMetadata().CanStartWith(typeof(FakeInitiatingEvent)));
            }
            public void ReturnFalseIfSagaCannotStartWithEventType()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanHandle((FakeHandledEvent e) => e.Id);

                Assert.False(configuration.GetMetadata().CanHandle(typeof(FakeUnhandledEvent)));
            }
            public void ReturnTrueIfSagaCanStartWithEventType()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanStartWith((FakeInitiatingEvent e) => e.Id);

                Assert.True(configuration.GetMetadata().CanStartWith(typeof(FakeInitiatingEvent)));
            }
            public void EventMarkedAsInitiatingEvent()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanHandle((FakeEvent e) => e.Id);

                Assert.True(configuration.GetMetadata().CanHandle(typeof(FakeEvent)));
            }
Example #7
0
            public WhenGettingEventCorrelationId()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanStartWith((FakeInitiatingEvent e) => e.Id);
                configuration.CanHandle((FakeHandledEvent e) => e.Id);

                sagaMetadata = configuration.GetMetadata();
            }
            public WhenGettingEventCorrelationId()
            {
                var configuration = new SagaConfiguration(typeof(FakeSaga));

                configuration.CanStartWith((FakeInitiatingEvent e) => e.Id);
                configuration.CanHandle((FakeHandledEvent e) => e.Id);

                sagaMetadata = configuration.GetMetadata();
            }
Example #9
0
        /// <summary>
        /// Gets the saga metadata for this saga instance.
        /// </summary>
        /// <remarks>Called once during saga discovery.</remarks>
        internal SagaMetadata GetMetadata()
        {
            Type sagaType = GetType();
            SagaMetadata sagaMetadata;

            if (!SagaMetadataCache.TryGetValue(sagaType, out sagaMetadata))
            {
                var configuration = new SagaConfiguration(GetType());

                Configure(configuration);
                SagaMetadataCache[sagaType] = sagaMetadata = configuration.GetMetadata();
            }

            return sagaMetadata;
        }