Example #1
0
        public void CanChangePlan_should_not_throw_exception_if_same_user_but_other_plan()
        {
            var command = new ChangePlan {
                PlanId = "basic", Actor = new RefToken("user", "me")
            };

            var plan = new AppPlan(command.Actor, "premium");

            GuardApp.CanChangePlan(command, App(plan), appPlans);
        }
Example #2
0
        public void CanChangePlan_should_not_throw_exception_if_plan_is_the_same()
        {
            var command = new ChangePlan {
                PlanId = "basic", Actor = RefToken.User("me")
            };

            var plan = new AppPlan(command.Actor, "basic");

            GuardApp.CanChangePlan(command, App(plan), appPlans);
        }
Example #3
0
        public void CanChangePlan_should_throw_exception_if_plan_not_found()
        {
            var command = new ChangePlan {
                PlanId = "notfound", Actor = new RefToken("user", "me")
            };

            AppPlan?plan = null;

            ValidationAssert.Throws(() => GuardApp.CanChangePlan(command, App(plan), appPlans),
                                    new ValidationError("A plan with this id does not exist.", "PlanId"));
        }
Example #4
0
        public void CanChangePlan_should_throw_exception_if_plan_id_is_null()
        {
            var command = new ChangePlan {
                Actor = new RefToken("user", "me")
            };

            AppPlan?plan = null;

            ValidationAssert.Throws(() => GuardApp.CanChangePlan(command, App(plan), appPlans),
                                    new ValidationError("Plan ID is required.", "PlanId"));
        }
Example #5
0
        public void CanChangePlan_should_throw_exception_if_plan_was_configured_from_another_user()
        {
            var command = new ChangePlan {
                PlanId = "basic", Actor = new RefToken("user", "me")
            };

            var plan = new AppPlan(new RefToken("user", "other"), "premium");

            ValidationAssert.Throws(() => GuardApp.CanChangePlan(command, App(plan), appPlans),
                                    new ValidationError("Plan can only changed from the user who configured the plan initially."));
        }