Ejemplo n.º 1
0
        /// <summary>
        /// Updates the current task
        /// </summary>
        /// <param name="text">The text of this task</param>
        /// <param name="size">The size complexity of this task</param>
        /// <param name="value">The business value of this task</param>
        /// <param name="owner">The user who owns this task</param>
        /// <param name="type">The type of this task</param>
        /// <param name="state">The state of this task</param>
        /// <param name="completion">The date this task was completed</param>
        /// <returns>True if the changes succeed, false otherwise</returns>
        public bool ChangeCurrTask(string text, int size, int value, UserView owner, TaskType type, TaskState state, Nullable<DateTime> completion)
        {
            if (!_isLoggedIn || CurrTask == null)
            {
                throw new InvalidOperationException("User must be logged in");
            }
            else if (owner == null && state != TaskState.Unassigned) // Giving an unassigned task any state but unassigned is not allowed
            {
                throw new InvalidOperationException("A task without an owner must be marked Unassigned");
            }
            else if (!EnumValues.businessValue.Contains(value) || !EnumValues.sizeComplexity.Contains(size))
            {
                throw new ArgumentOutOfRangeException("Invalid complexity value");
            }
            else if (text == null)
            {
                throw new ArgumentNullException("Arguments to AddTask must not be null");
            }

            bool result = _dataModel.ChangeTask(CurrTask.TaskID, text, size, value, owner == null ? null : new int?(owner.UserID), type.ConvertToBinary(), state.ConvertToBinary(), completion);
            if (result)
            {
                updateTasksForStory();
                updateTasksForUser();
                CurrTask = new TaskView(_dataModel.GetTaskByID(CurrTask.TaskID));
            }

            return result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the current project, sprint, and story from a selected task
        /// </summary>
        /// <param name="task">The selected task</param>
        public void JumpToTask(TaskView task)
        {
            if (!_isLoggedIn)
            {
                throw new InvalidOperationException("User must be logged in");
            }
            else if (task == null) // Bad input value
            {
                throw new ArgumentNullException("Arguments to JumpToTask must not be null");
            }

            CurrStory = new StoryView(_dataModel.GetStoryByID(task.StoryID));
            CurrSprint = new SprintView(_dataModel.GetSprintByID(CurrStory.SprintID));
            CurrProject = new ProjectView(_dataModel.GetProjectByID(CurrSprint.ProjectID));
            CurrTask = task;
        }
        public void JumpToTaskTest()
        {
            TaskView task = null;

            target._isLoggedIn = false;
            try
            {
                target.JumpToTask(task);
                Assert.Fail("Exception not thrown");
            }
            catch (InvalidOperationException)
            {
                ;
            }

            target._isLoggedIn = true;
            try
            {
                target.JumpToTask(task);
                Assert.Fail("Exception not thrown");
            }
            catch (ArgumentNullException)
            {
                ;
            }

            task = new TaskView(target._dataModel.GetTaskByID(1));
            target.JumpToTask(task);
            Assert.AreEqual(task.TaskID, target.CurrTask.TaskID);
        }