public Task CanAssign_should_not_throw_exception_if_user_found() { var command = new AssignContributor { ContributorId = "1" }; return(GuardAppContributors.CanAssign(contributors, command, users, appPlan)); }
public Task CanAssign_should_throw_exception_if_permission_not_valid() { var command = new AssignContributor { ContributorId = "1", Permission = (AppContributorPermission)10 }; return(Assert.ThrowsAsync <ValidationException>(() => GuardAppContributors.CanAssign(contributors, command, users, appPlan))); }
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 Task CanAssign_should_not_throw_exception_if_contributor_has_another_permission() { var command = new AssignContributor { ContributorId = "1" }; contributors.Assign("1", AppContributorPermission.Editor); return(GuardAppContributors.CanAssign(contributors, command, users, appPlan)); }
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))); }
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))); }
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)); }
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))); }