示例#1
0
 private void CheckForSubtasksForAssignmentAndCreateIfNecessary(int assignment_id)
 {
     try
     {
         var subtaskLogic     = new SubtaskLogic();
         var existingSubtasks = subtaskLogic.GetByAssignmentId(assignment_id);
         if (existingSubtasks == null || existingSubtasks.Count() == 0)
         {
             var assignmentLogic = new AssignmentLogic();
             var assignment      = assignmentLogic.GetAssignmentById(assignment_id);
             var defaultSubtask  = new SubtaskCreateViewModel
             {
                 Name        = assignment.Name,
                 Description = assignment.Description,
                 Priority    = EnumDefinition.SubtaskPriority.Medium
             };
             assignmentLogic.AddSubtask(assignment_id, defaultSubtask);
             assignmentLogic.Dispose();
         }
         subtaskLogic.Dispose();
     }
     catch (Exception e)
     {
         Logger.LogException(e);
         MessageBox.Show(e.Message);
     }
 }
        public void AddSubtask_Test()
        {
            // ARRANGE
            var assignment         = CreateTestAssignment();
            var assignmentLogic    = new AssignmentLogic();
            var subtaskCreateParam = new SubtaskCreateParam
            {
                Description = "Test description",
                Name        = "Test subtask",
                Priority    = EnumDefinition.SubtaskPriority.High
            };

            // ACT
            assignmentLogic.AddSubtask(assignment.Id, subtaskCreateParam);
            assignmentLogic.Dispose();
            this.uow.Dispose();
            this.uow = new UnitOfWork();

            // ASSERT
            var subtask = this.uow.Subtasks.Load(s => s.Assignment_Id == assignment.Id).First();

            Assert.IsNotNull(subtask);
        }