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"]); }
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"]); }
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))); }
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"]); }
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); }
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")); }
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.")); }
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"))); }
public static AppContributors Apply(this AppContributors contributors, AppContributorAssigned @event) { return(contributors.Assign(@event.ContributorId, @event.Permission)); }
public void HandleCommand(CreateApp command) { version++; contributors = contributors.Assign(command.Actor.Identifier, Role.Developer); }
public static void Apply(this AppContributors contributors, AppContributorAssigned @event) { contributors.Assign(@event.ContributorId, @event.Permission); }