Example #1
0
        private static IMobStator <User, UserSubscription> GetMobStatorForTwoEntities()
        {
            var statorForUser = Stator <User, UserStatus> .InitStator()
                                .State(x => x.Status)
                                .ForEvent <UserBlockedEvent>()
                                .SetTransition(UserStatus.Active, UserStatus.Inactive).ConfirmTransition()
                                .SetTransition(UserStatus.Premium, UserStatus.Inactive).ConfirmTransition()
                                .SetTransition(UserStatus.Striked, UserStatus.Deleted).ConfirmTransition()
                                .ConfirmEvent()
                                .Build();

            var statorForSubscription = Stator <UserSubscription, SubscriptionStatus> .InitStator()
                                        .State(x => x.Status)
                                        .ForEvent <UserBlockedEvent>()
                                        .SetTransition(SubscriptionStatus.Active, SubscriptionStatus.Closed).ConfirmTransition()
                                        .SetTransition(SubscriptionStatus.Pending, SubscriptionStatus.Closed).ConfirmTransition()
                                        .ConfirmEvent()
                                        .Build();

            var mobStator =
                MobStatorFactory
                .InitWithStator(statorForUser)
                .AddStateMachine(statorForSubscription)
                .Build();

            return(mobStator);
        }
Example #2
0
        private static IMobStator <User, UserSubscription> GetBrokenMobStatorForTwoEntities(bool withRollbackOnFailure)
        {
            var statorForUser = Stator <User, UserStatus> .InitStator()
                                .State(x => x.Status)
                                .ForEvent <UserBlockedEvent>()
                                .SetTransition(UserStatus.Active, UserStatus.Inactive).ConfirmTransition()
                                .ConfirmEvent()
                                .Build();

            var statorForSubscription = Stator <UserSubscription, SubscriptionStatus> .InitStator()
                                        .State(x => x.Status)
                                        .ForEvent <UserBlockedEvent>()
                                        .SetTransition(SubscriptionStatus.Active, SubscriptionStatus.Closed)
                                        .WithActionAfterTransition((x, y) => throw new Exception())
                                        .ConfirmTransition()
                                        .ConfirmEvent()
                                        .Build();

            var mobStator =
                MobStatorFactory
                .InitWithStator(statorForUser, withRollbackOnFailure)
                .AddStateMachine(statorForSubscription)
                .Build();

            return(mobStator);
        }
Example #3
0
        private static IMobStator GetBrokenMobStatorWithFiveEntities(bool withRollbackOnFailure)
        {
            var statorForUser = Stator <User, UserStatus> .InitStator()
                                .State(x => x.Status)
                                .ForEvent <UserBlockedEvent>()
                                .SetTransition(UserStatus.Active, UserStatus.Inactive).ConfirmTransition()
                                .SetTransition(UserStatus.Premium, UserStatus.Inactive).ConfirmTransition()
                                .SetTransition(UserStatus.Striked, UserStatus.Deleted).ConfirmTransition()
                                .ConfirmEvent()
                                .Build();

            var statorForSubscription = Stator <UserSubscription, SubscriptionStatus> .InitStator()
                                        .State(x => x.Status)
                                        .ForEvent <UserBlockedEvent>()
                                        .SetTransition(SubscriptionStatus.Active, SubscriptionStatus.Closed).ConfirmTransition()
                                        .SetTransition(SubscriptionStatus.Pending, SubscriptionStatus.Closed).ConfirmTransition()
                                        .ConfirmEvent()
                                        .Build();

            var statorForPersonalSpace = Stator <PersonalSpace, PersonalSpaceStatus> .InitStator()
                                         .State(x => x.Status)
                                         .ForEvent <UserBlockedEvent>()
                                         .SetTransition(PersonalSpaceStatus.Granted, PersonalSpaceStatus.Blocked)
                                         .WithActionAfterTransition((x, y) => throw new Exception())
                                         .ConfirmTransition()
                                         .ConfirmEvent()
                                         .Build();

            var statorForAccount = Stator <Account, AccountStatus> .InitStator()
                                   .State(x => x.Status)
                                   .ForEvent <UserBlockedEvent>()
                                   .SetTransition(AccountStatus.Existed, AccountStatus.Deleted).ConfirmTransition()
                                   .SetTransition(AccountStatus.Blocked, AccountStatus.Deleted).ConfirmTransition()
                                   .ConfirmEvent()
                                   .Build();

            var statorForRanking = Stator <Ranking, RankingStatus> .InitStator()
                                   .State(x => x.Status)
                                   .ForEvent <UserBlockedEvent>()
                                   .SetTransition(RankingStatus.Tracked, RankingStatus.Untracked).ConfirmTransition()
                                   .ConfirmEvent()
                                   .Build();

            var mobStator =
                MobStatorFactory
                .InitWithStator(statorForUser, withRollbackOnFailure)
                .AddStateMachine(statorForSubscription)
                .AddStateMachine(statorForAccount)
                .AddStateMachine(statorForPersonalSpace)
                .AddStateMachine(statorForRanking)
                .Build();

            return(mobStator);
        }
Example #4
0
        private static IMobStator GetMobStatorForFiveInconsistentEntities()
        {
            var statorForUser = Stator <User, UserStatus> .InitStator()
                                .State(x => x.Status)
                                .ForEvent <UserBlockedEvent>()
                                .SetTransition(UserStatus.Active, UserStatus.Inactive).ConfirmTransition()
                                .SetTransition(UserStatus.Premium, UserStatus.Inactive).ConfirmTransition()
                                .SetTransition(UserStatus.Striked, UserStatus.Deleted).ConfirmTransition()
                                .ConfirmEvent()
                                .Build();

            var statorForSubscription = Stator <UserSubscription, SubscriptionStatus> .InitStator()
                                        .State(x => x.Status)
                                        .ForEvent <UserBlockedEvent>()
                                        .SetTransition(SubscriptionStatus.Active, SubscriptionStatus.Closed).ConfirmTransition()
                                        .SetTransition(SubscriptionStatus.Pending, SubscriptionStatus.Closed).ConfirmTransition()
                                        .ConfirmEvent()
                                        .Build();

            var statorForAccount = Stator <Account, AccountStatus> .InitStator()
                                   .State(x => x.Status)
                                   .ForEvent <UserBlockedEvent>()
                                   .SetTransition(AccountStatus.Existed, AccountStatus.Deleted).ConfirmTransition()
                                   .SetTransition(AccountStatus.Blocked, AccountStatus.Deleted).ConfirmTransition()
                                   .ConfirmEvent()
                                   .Build();

            var statorForAccountDuple = Stator <Account, AccountStatus> .InitStator()
                                        .State(x => x.Status)
                                        .ForEvent <UserBlockedEvent>()
                                        .SetTransition(AccountStatus.Existed, AccountStatus.Deleted).ConfirmTransition()
                                        .SetTransition(AccountStatus.Blocked, AccountStatus.Deleted).ConfirmTransition()
                                        .ConfirmEvent()
                                        .Build();

            var statorForRanking = Stator <Ranking, RankingStatus> .InitStator()
                                   .State(x => x.Status)
                                   .ForEvent <UserBlockedEvent>()
                                   .SetTransition(RankingStatus.Tracked, RankingStatus.Untracked).ConfirmTransition()
                                   .ConfirmEvent()
                                   .Build();

            var mobStator =
                MobStatorFactory
                .InitWithStator(statorForUser)
                .AddStateMachine(statorForSubscription)
                .AddStateMachine(statorForAccount)
                .AddStateMachine(statorForAccountDuple)
                .AddStateMachine(statorForRanking)
                .Build();

            return(mobStator);
        }