Example #1
0
        public void CanUpdateSettings_should_throw_exception_if_settings_is_null()
        {
            var command = new UpdateAppSettings();

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Settings is required.", "Settings"));
        }
Example #2
0
        public void CanUploadImage_should_throw_exception_if_name_not_valid()
        {
            var command = new UploadAppImage();

            ValidationAssert.Throws(() => GuardApp.CanUploadImage(command),
                                    new ValidationError("File is required.", "File"));
        }
Example #3
0
        public void CanUploadImage_should_not_throw_exception_if_app_name_is_valid()
        {
            var command = new UploadAppImage {
                File = new NoopAssetFile()
            };

            GuardApp.CanUploadImage(command);
        }
Example #4
0
        public void CanCreate_should_not_throw_exception_if_app_name_is_valid()
        {
            var command = new CreateApp {
                Name = "new-app"
            };

            GuardApp.CanCreate(command);
        }
Example #5
0
        public void CanCreate_should_throw_exception_if_name_not_valid()
        {
            var command = new CreateApp {
                Name = "INVALID NAME"
            };

            ValidationAssert.Throws(() => GuardApp.CanCreate(command),
                                    new ValidationError("Name is not a valid slug.", "Name"));
        }
Example #6
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 #7
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 #8
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 #9
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 #10
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."));
        }
Example #11
0
        public void CanUpdateSettings_should_throw_exception_if_editors_is_null()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Editors = null !
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Editors is required.", "Settings.Editors"));
        }
Example #12
0
        public void CanUpdateSettings_should_throw_exception_if_patterns_has_null_url()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Editors = ReadonlyList.Create(
                        new Editor("name", null !))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Url is required.", "Settings.Editors[0].Url"));
        }
Example #13
0
        public void CanUpdateSettings_should_throw_exception_if_editors_has_null_name()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Editors = ReadonlyList.Create(
                        new Editor(null !, "[a-z]"))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Name is required.", "Settings.Editors[0].Name"));
        }
Example #14
0
        public void CanUpdateSettings_should_throw_exception_if_patterns_has_null_regex()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Patterns = ReadonlyList.Create(
                        new Pattern("name", null !))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Regex is required.", "Settings.Patterns[0].Regex"));
        }
Example #15
0
        public void CanUpdateSettings_should_throw_exception_if_patterns_has_null_name()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Patterns = ReadOnlyCollection.Create(
                        new Pattern(null !, "[a-z]"))
                }
            };

            ValidationAssert.Throws(() => GuardApp.CanUpdateSettings(command),
                                    new ValidationError("Name is required.", "Settings.Patterns[0].Name"));
        }
Example #16
0
        public void CanUpdateSettings_should_not_throw_exception_if_setting_is_valid()
        {
            var command = new UpdateAppSettings
            {
                Settings = new AppSettings
                {
                    Patterns = ReadonlyList.Create(
                        new Pattern("name", "[a-z]")),
                    Editors = ReadonlyList.Create(
                        new Editor("name", "url/to/editor"))
                }
            };

            GuardApp.CanUpdateSettings(command);
        }