コード例 #1
0
        public void Should_assign_new_contributor()
        {
            var contributors_1 = contributors_0.Assign("1", Role.Developer);
            var contributors_2 = contributors_1.Assign("2", Role.Editor);

            Assert.Equal(Role.Developer, contributors_2["1"]);
            Assert.Equal(Role.Editor, contributors_2["2"]);
        }
コード例 #2
0
        public void Should_assign_new_contributor()
        {
            var contributors_1 = contributors_0.Assign("1", AppContributorPermission.Developer);
            var contributors_2 = contributors_1.Assign("2", AppContributorPermission.Editor);

            Assert.Equal(AppContributorPermission.Developer, contributors_2["1"]);
            Assert.Equal(AppContributorPermission.Editor, contributors_2["2"]);
        }
コード例 #3
0
        public Task CanAssign_should_throw_exception_if_user_already_exists_with_same_permission()
        {
            var command = new AssignContributor {
                ContributorId = "1"
            };

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

            return(Assert.ThrowsAsync <ValidationException>(() => GuardAppContributors.CanAssign(contributors, command, users, appPlan)));
        }
コード例 #4
0
        public void Should_assign_new_contributor()
        {
            sut.Assign("1", AppContributorPermission.Developer);
            sut.Assign("2", AppContributorPermission.Editor);

            Assert.Equal(AppContributorPermission.Developer, sut["1"]);
            Assert.Equal(AppContributorPermission.Editor, sut["2"]);
        }
コード例 #5
0
        public async Task CanAssign_should_not_throw_exception_if_user_already_exists_with_same_role()
        {
            var command = new AssignContributor {
                ContributorId = "1", Role = Role.Owner
            };

            var contributors_1 = contributors_0.Assign("1", Role.Owner);

            await GuardAppContributors.CanAssign(command, App(contributors_1), users, appPlan);
        }
コード例 #6
0
        public async Task CanAssign_should_throw_exception_if_user_already_exists_with_same_role()
        {
            var command = new AssignContributor {
                ContributorId = "1", Role = Role.Owner
            };

            var contributors_1 = contributors_0.Assign("1", Role.Owner);

            await ValidationAssert.ThrowsAsync(() => GuardAppContributors.CanAssign(contributors_1, roles, command, users, appPlan),
                                               new ValidationError("Contributor has already this role.", "Role"));
        }
コード例 #7
0
        public void CanDelete_should_throw_exception_if_contributor_found()
        {
            var roles_1 = roles_0.Add(roleName);

            var command = new DeleteRole {
                Name = roleName
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanDelete(roles_1, command, contributors.Assign("1", roleName), clients),
                                    new ValidationError("Cannot remove a role when a contributor is assigned."));
        }
コード例 #8
0
        public Task CanAssign_should_throw_exception_if_user_already_exists_with_same_permission()
        {
            var command = new AssignContributor {
                ContributorId = "1"
            };

            var contributors_1 = contributors_0.Assign("1", AppContributorPermission.Owner);

            return(ValidationAssert.ThrowsAsync(() => GuardAppContributors.CanAssign(contributors_1, command, users, appPlan),
                                                new ValidationError("Contributor has already this permission.", "Permission")));
        }
コード例 #9
0
 public static AppContributors Apply(this AppContributors contributors, AppContributorAssigned @event)
 {
     return(contributors.Assign(@event.ContributorId, @event.Permission));
 }
コード例 #10
0
            public void HandleCommand(CreateApp command)
            {
                version++;

                contributors = contributors.Assign(command.Actor.Identifier, Role.Developer);
            }
コード例 #11
0
 public static void Apply(this AppContributors contributors, AppContributorAssigned @event)
 {
     contributors.Assign(@event.ContributorId, @event.Permission);
 }