protected bool HandleChangeStage(ChangeStageAction action) { switch (action.Stage) { case TaskStage.Unassigned: this.Assignee = null; break; case TaskStage.Assigned: if (this.Assignee == null) { throw new TaskUnassignedException(this); } break; // TODO test case TaskStage.Finalized: if (this.AutoDump) { this.OnSend(new DumpTokensAction(string.Empty, this.Address)); } break; default: break; } this.Stage = action.Stage; return(true); }
public void SplitReward_AccordingToTheHours() { var task = this.CreateTask(null); this.CreateTokenInteractionPermissions(task.Address); var mintAction = new MintAction(string.Empty, this.tokenManager.Address, 160, task.Address); this.permissionManager.ExecuteAction(mintAction); var employee1 = this.addressFactory.Create(); var employee2 = this.addressFactory.Create(); var employee3 = this.addressFactory.Create(); this.TrackHours_ReturnsSplitterTrack(employee1, task.Address, 5); this.TrackHours_ReturnsSplitterTrack(employee2, task.Address, 15); this.TrackHours_ReturnsSplitterTrack(employee3, task.Address, 20); var stageAction = new ChangeStageAction(string.Empty, task.Address, TaskStage.Finalized); this.permissionManager.ExecuteAction(stageAction); var employee1Tokens = this.tokenManager.TaggedBalanceOf(employee1).TotalBalance; var employee2Tokens = this.tokenManager.TaggedBalanceOf(employee2).TotalBalance; var employee3Tokens = this.tokenManager.TaggedBalanceOf(employee3).TotalBalance; Assert.Equal(20, employee1Tokens); Assert.Equal(60, employee2Tokens); Assert.Equal(80, employee3Tokens); }
public void ChangeStage_WhenUnAssigned_ThrowsException() { var assignee = this.addressFactory.Create(); var task = this.CreateTask(null); var action = new ChangeStageAction(string.Empty, task.Address, TaskStage.Assigned); Assert.Throws <TaskUnassignedException>(() => this.permissionManager.ExecuteAction(action)); }
public void ChangeStage_WhenAssigned_RemoveAssignee() { var assignee = this.addressFactory.Create(); var task = this.CreateTask(assignee); var action = new ChangeStageAction(string.Empty, task.Address, TaskStage.Unassigned); this.permissionManager.ExecuteAction(action); Assert.Null(task.Assignee); Assert.Equal(TaskStage.Unassigned, task.Stage); }