コード例 #1
0
        public void AddNewTaskTest()
        {
            var newTask = new TaskEntity()
            {
                Task_ID    = 2,
                Parent_ID  = 2,
                Project_ID = 2,
                Task1      = "DAL Layer -2",
                Start_Date = Convert.ToDateTime("2018-12-28"),
                End_Date   = Convert.ToDateTime("2018-12-31"),
                Priority   = "20",
                Status     = null
            };

            var maxTaskIDBeforeAdd = _task.Max(a => a.Task_ID);

            newTask.Task_ID = maxTaskIDBeforeAdd + 1;

            _taskService.CreateTask(newTask);
            var addedTask = new Task()
            {
                Task_ID    = newTask.Task_ID,
                Parent_ID  = newTask.Parent_ID,
                Project_ID = newTask.Project_ID,
                Task1      = newTask.Task1,
                Start_Date = newTask.Start_Date,
                End_Date   = newTask.End_Date,
                Priority   = newTask.Priority,
                Status     = newTask.Status
            };

            AssertObjects.PropertyValuesAreEquals(addedTask, _task.Last());
            Assert.That(maxTaskIDBeforeAdd + 1, Is.EqualTo(newTask.Task_ID));
        }
コード例 #2
0
        public void CreateTaskTest()
        {
            var taskController = new TaskController()
            {
                Request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(ServiceBaseURL + "Create")
                }
            };

            taskController.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            var newTask = new TaskEntity()
            {
                Task_ID    = 2,
                Parent_ID  = 2,
                Project_ID = 2,
                Task1      = "DAL Layer -3",
                Start_Date = Convert.ToDateTime("2018-12-28"),
                End_Date   = Convert.ToDateTime("2018-12-31"),
                Priority   = "20",
                Status     = null
            };

            taskController.Post(newTask);

            _response = taskController.Get();
            var responseResultSearch = JsonConvert.DeserializeObject <List <vw_TaskSearch> >(_response.Content.ReadAsStringAsync().Result);
            var taskList             =
                responseResultSearch.Select(
                    taskEntity =>
                    new Task
            {
                Task_ID    = taskEntity.Task_ID,
                Parent_ID  = taskEntity.TaskParentID,
                Project_ID = taskEntity.TaskProjectID,
                Task1      = taskEntity.TaskName,
                Start_Date = taskEntity.Start_Date,
                End_Date   = taskEntity.End_Date,
                Priority   = taskEntity.TaskPriority,
                Status     = taskEntity.TaskStatus
            }).ToList();
            var addedtask = new Task()
            {
                Task_ID    = newTask.Task_ID,
                Parent_ID  = newTask.Parent_ID,
                Project_ID = newTask.Project_ID,
                Task1      = newTask.Task1,
                Start_Date = newTask.Start_Date,
                End_Date   = newTask.End_Date,
                Priority   = newTask.Priority,
                Status     = newTask.Status
            };

            AssertObjects.PropertyValuesAreEquals(addedtask, taskList.Last());
        }
コード例 #3
0
 /// <summary>
 /// Creates a task
 /// </summary>
 /// <param name="TaskEntity"></param>
 /// <returns></returns>
 public int CreateTask(TaskEntity taskEntity)
 {
     using (var scope = new TransactionScope())
     {
         var task = new Task
         {
             Parent_ID  = taskEntity.Parent_ID,
             Project_ID = taskEntity.Project_ID,
             TaskName   = taskEntity.TaskName,
             Start_Date = taskEntity.Start_Date,
             End_Date   = taskEntity.End_Date,
             Priority   = taskEntity.Priority,
             Status     = taskEntity.Status
         };
         _unitOfWork.TaskRepository.Insert(task);
         _unitOfWork.Save();
         scope.Complete();
         return(task.Task_ID);
     }
 }