PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/Bifrost.Specs/Sagas/for_SagaState/when_in_a_state_of_concluded.cs

#
C# | 36 lines | 30 code | 6 blank | 0 comment | 0 complexity | 1b0a209c1cf9d0d248da47375db28349 MD5 | raw file
 1using System;
 2using Bifrost.Sagas;
 3using Bifrost.Sagas.Exceptions;
 4using Machine.Specifications;
 5
 6namespace Bifrost.Specs.Sagas.for_SagaState
 7{
 8    [Subject(typeof(SagaState))]
 9    public class when_in_a_state_of_concluded : given.a_state_of_concluded
10    {
11        static Exception exception_when_transitioning_to_an_invalid_state;
12
13        static bool can_transition_to_new;
14        static bool can_transition_to_begun;
15        static bool can_transition_to_continuing;
16        static bool can_transition_to_concluded;
17
18        Because of = () =>
19        {
20            can_transition_to_new = state.CanTransitionTo(SagaState.NEW);
21            can_transition_to_begun = state.CanTransitionTo(SagaState.BEGUN);
22            can_transition_to_continuing = state.CanTransitionTo(SagaState.CONTINUING);
23            can_transition_to_concluded = state.CanTransitionTo(SagaState.CONCLUDED);
24
25            exception_when_transitioning_to_an_invalid_state = exception_when_transitioning_to_an_invalid_state = Catch.Exception(() => state.TransitionTo(SagaState.BEGUN));
26        };
27
28        It should_not_support_transitioning_to_new = () => can_transition_to_new.ShouldBeFalse();
29        It should_not_support_transitioning_to_begun = () => can_transition_to_begun.ShouldBeFalse();
30        It should_not_support_transitioning_to_continuing = () => can_transition_to_continuing.ShouldBeFalse();
31        It should_support_transitioning_to_concluded = () => can_transition_to_concluded.ShouldBeFalse();
32
33        It should_throw_an_invalid_saga_state_transition_exception_when_transitioning_to_an_invalid_state =
34            () => exception_when_transitioning_to_an_invalid_state.ShouldBeOfType<InvalidSagaStateTransitionException>();
35    }
36}