Пример #1
0
        public Task CanAssign_should_throw_exception_if_user_not_found()
        {
            A.CallTo(() => users.FindByIdAsync(A <string> .Ignored))
            .Returns(Task.FromResult <IUser>(null));

            var command = new AssignContributor {
                ContributorId = "1", Permission = (AppContributorPermission)10
            };

            return(Assert.ThrowsAsync <ValidationException>(() => GuardAppContributors.CanAssign(contributors, command, users, appPlan)));
        }
Пример #2
0
        public void CanRemove_should_not_throw_exception_if_contributor_not_only_owner()
        {
            var command = new RemoveContributor {
                ContributorId = "1"
            };

            contributors.Assign("1", AppContributorPermission.Owner);
            contributors.Assign("2", AppContributorPermission.Owner);

            GuardAppContributors.CanRemove(contributors, command);
        }
Пример #3
0
        public void CanRemove_should_throw_exception_if_contributor_is_only_owner()
        {
            var command = new RemoveContributor {
                ContributorId = "1"
            };

            contributors.Assign("1", AppContributorPermission.Owner);
            contributors.Assign("2", AppContributorPermission.Editor);

            Assert.Throws <ValidationException>(() => GuardAppContributors.CanRemove(contributors, command));
        }
Пример #4
0
        public Task CanAssign_should_throw_exception_if_contributor_max_reached()
        {
            A.CallTo(() => appPlan.MaxContributors)
            .Returns(2);

            var command = new AssignContributor {
                ContributorId = "3"
            };

            contributors.Assign("1", AppContributorPermission.Owner);
            contributors.Assign("2", AppContributorPermission.Editor);

            return(Assert.ThrowsAsync <ValidationException>(() => GuardAppContributors.CanAssign(contributors, command, users, appPlan)));
        }
Пример #5
0
        public Task CanAssign_should_not_throw_exception_if_contributor_max_reached_but_permission_changed()
        {
            A.CallTo(() => appPlan.MaxContributors)
            .Returns(2);

            var command = new AssignContributor {
                ContributorId = "1"
            };

            contributors.Assign("1", AppContributorPermission.Editor);
            contributors.Assign("2", AppContributorPermission.Editor);

            return(GuardAppContributors.CanAssign(contributors, command, users, appPlan));
        }
Пример #6
0
        public Task CanAssign_should_throw_exception_if_contributor_id_is_null()
        {
            var command = new AssignContributor();

            return(Assert.ThrowsAsync <ValidationException>(() => GuardAppContributors.CanAssign(contributors, command, users, appPlan)));
        }
Пример #7
0
        public void CanRemove_should_throw_exception_if_contributor_id_is_null()
        {
            var command = new RemoveContributor();

            Assert.Throws <ValidationException>(() => GuardAppContributors.CanRemove(contributors, command));
        }