Esempio n. 1
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"));
        }
Esempio n. 2
0
        public void CanCreate_should_not_throw_exception_if_app_name_is_valid()
        {
            var command = new CreateApp {
                Name = "new-app"
            };

            GuardApp.CanCreate(command);
        }
Esempio n. 3
0
        public Task CanCreate_should_not_throw_exception_if_app_name_is_free()
        {
            var command = new CreateApp {
                Name = "new-app"
            };

            return(GuardApp.CanCreate(command, apps));
        }
Esempio n. 4
0
        public void CanUploadImage_should_not_throw_exception_if_app_name_is_valid()
        {
            var command = new UploadAppImage {
                File = new AssetFile("file.png", "image/png", 100, () => new MemoryStream())
            };

            GuardApp.CanUploadImage(command);
        }
Esempio n. 5
0
        public Task CanCreate_should_throw_exception_if_name_not_valid()
        {
            var command = new CreateApp {
                Name = "INVALID NAME"
            };

            return(Assert.ThrowsAsync <ValidationException>(() => GuardApp.CanCreate(command, apps)));
        }
Esempio n. 6
0
        public void CanUploadImage_should_not_throw_exception_if_app_name_is_valid()
        {
            var command = new UploadAppImage {
                File = new NoopAssetFile()
            };

            GuardApp.CanUploadImage(command);
        }
Esempio n. 7
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"));
        }
Esempio n. 8
0
        public Task CanCreate_should_throw_exception_if_name_not_valid()
        {
            var command = new CreateApp {
                Name = "INVALID NAME"
            };

            return(ValidationAssert.ThrowsAsync(() => GuardApp.CanCreate(command, apps),
                                                new ValidationError("Name must be a valid slug.", "Name")));
        }
Esempio n. 9
0
        public Task CanCreate_should_throw_exception_if_name_already_in_use()
        {
            var command = new CreateApp {
                Name = "existing"
            };

            return(ValidationAssert.ThrowsAsync(() => GuardApp.CanCreate(command, apps),
                                                new ValidationError("An app with the same name already exists.", "Name")));
        }
Esempio n. 10
0
        public void CanChangePlan_should_throw_exception_if_plan_id_null()
        {
            var command = new ChangePlan {
                Actor = new RefToken("user", "me")
            };

            AppPlan plan = null;

            Assert.Throws <ValidationException>(() => GuardApp.CanChangePlan(command, plan, appPlans));
        }
Esempio n. 11
0
        public void CanChangePlan_should_throw_exception_if_plan_is_the_same()
        {
            var command = new ChangePlan {
                PlanId = "free", Actor = new RefToken("user", "me")
            };

            var plan = new AppPlan(new RefToken("user", "me"), "free");

            Assert.Throws <ValidationException>(() => GuardApp.CanChangePlan(command, plan, appPlans));
        }
Esempio n. 12
0
        public void CanChangePlan_should_not_throw_exception_if_plan_is_the_same()
        {
            var command = new ChangePlan {
                PlanId = "basic", Actor = new RefToken("user", "me")
            };

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

            GuardApp.CanChangePlan(command, App(plan), appPlans);
        }
Esempio n. 13
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, plan, appPlans);
        }
Esempio n. 14
0
        public void CanChangePlan_should_throw_exception_if_plan_was_configured_from_another_user()
        {
            var command = new ChangePlan {
                PlanId = "free", Actor = new RefToken("user", "me")
            };

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

            Assert.Throws <ValidationException>(() => GuardApp.CanChangePlan(command, plan, appPlans));
        }
Esempio n. 15
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, plan, appPlans),
                                    new ValidationError("A plan with this id does not exist.", "PlanId"));
        }
Esempio n. 16
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, plan, appPlans),
                                    new ValidationError("Plan id is required.", "PlanId"));
        }
Esempio n. 17
0
        public Task CanCreate_should_throw_exception_if_name_already_in_use()
        {
            A.CallTo(() => apps.GetAppAsync("new-app"))
            .Returns(A.Fake <IAppEntity>());

            var command = new CreateApp {
                Name = "new-app"
            };

            return(Assert.ThrowsAsync <ValidationException>(() => GuardApp.CanCreate(command, apps)));
        }
Esempio n. 18
0
        public void CanChangePlan_should_throw_exception_if_plan_is_the_same()
        {
            var command = new ChangePlan {
                PlanId = "basic", Actor = new RefToken("user", "me")
            };

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

            ValidationAssert.Throws(() => GuardApp.CanChangePlan(command, plan, appPlans),
                                    new ValidationError("App has already this plan."));
        }
Esempio n. 19
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, plan, appPlans),
                                    new ValidationError("Plan can only changed from the user who configured the plan initially."));
        }
Esempio n. 20
0
        public void CanChangePlan_should_throw_exception_if_plan_not_found()
        {
            A.CallTo(() => appPlans.GetPlan("free"))
            .Returns(null);

            var command = new ChangePlan {
                PlanId = "free", Actor = new RefToken("user", "me")
            };

            AppPlan plan = null;

            Assert.Throws <ValidationException>(() => GuardApp.CanChangePlan(command, plan, appPlans));
        }