コード例 #1
0
 public bool UpdateTask(int taskId, Models.ViewModels.Task taskModel)
 {
     if (taskRepository.GetById(taskId) != null && taskModel.TaskId == taskId)
     {
         return(taskRepository.Update(taskModel.AsDataModel()));
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        public void Test_For_Get_Task_By_Id()
        {
            // Arrange
            var testTaskId = 5;
            var testTaskVM = new Models.ViewModels.Task()
            {
                TaskId        = testTaskId,
                TaskName      = "TestTask1",
                Priority      = 20,
                ProjectName   = "TestProject100",
                OwnerFullName = "First Last",
                StartDate     = DateTime.Today
            };

            mockTaskRepo.Setup(repo => repo.GetById(testTaskId)).Returns(testTaskVM.AsDataModel());
            // Act
            var actualTask = tasksLogicTest.GetTask(testTaskId);

            // Assert
            Assert.NotNull(actualTask);
            Assert.Equal(testTaskVM.TaskName, actualTask.TaskName);
        }
コード例 #3
0
        public void Test_For_Converting_AsDataModel_List()
        {
            // Arrange
            var tasksList = new Models.ViewModels.Task[] {
                new Models.ViewModels.Task()
                {
                    ProjectId = 1, ProjectName = "TestProject-1", TaskOwnerId = Guid.NewGuid(), Priority = 10, TaskId = 10, TaskName = "TestTask1"
                },
                new Models.ViewModels.Task()
                {
                    ProjectId = 2, ProjectName = "TestProject-2", TaskOwnerId = Guid.NewGuid(), Priority = 5, TaskId = 11, TaskName = "TestTask2"
                },
                new Models.ViewModels.Task()
                {
                    ProjectId = 3, ProjectName = "TestProject-3", TaskOwnerId = Guid.NewGuid(), Priority = 15, TaskId = 9, TaskName = "TestTask3"
                },
                new Models.ViewModels.Task()
                {
                    ProjectId = 4, ProjectName = "TestProject-4", TaskOwnerId = Guid.NewGuid(), Priority = 20, TaskId = 7, TaskName = "TestTask4"
                },
                new Models.ViewModels.Task()
                {
                    ProjectId = 5, ProjectName = "TestProject-5", TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "TestTask5", ParentTaskName = "TestParentTask1", ParentTaskId = 200
                },
                new Models.ViewModels.Task()
                {
                    ProjectId = 6, ProjectName = "TestProject-5", TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "TestTask6", ParentTaskName = "TestParentTask1", ParentTaskId = 200
                },
                new Models.ViewModels.Task()
                {
                    ProjectId = 7, ProjectName = "TestProject-5", TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "TestTask7", ParentTaskName = "TestParentTask2", ParentTaskId = 202
                },
            }.AsEnumerable();

            var testDataModelList = new Models.DataModels.Task[] {
                new Models.DataModels.Task()
                {
                    ProjectId = 1, Project = new Models.DataModels.Project()
                    {
                        ProjectName = "test-1", ProjectId = 1
                    }, TaskOwnerId = Guid.NewGuid(), Priority = 10, TaskId = 10, TaskName = "As-Is-Task1"
                },
                new Models.DataModels.Task()
                {
                    ProjectId = 2, Project = new Models.DataModels.Project()
                    {
                        ProjectName = "test-2", ProjectId = 2
                    }, TaskOwnerId = Guid.NewGuid(), Priority = 5, TaskId = 11, TaskName = "As-Is-Task2"
                },
                new Models.DataModels.Task()
                {
                    ProjectId = 3, Project = new Models.DataModels.Project()
                    {
                        ProjectName = "test-3", ProjectId = 3
                    }, TaskOwnerId = Guid.NewGuid(), Priority = 15, TaskId = 9, TaskName = "As-Is-Task3"
                },
                new Models.DataModels.Task()
                {
                    ProjectId = 4, Project = new Models.DataModels.Project()
                    {
                        ProjectName = "test-4", ProjectId = 4
                    }, TaskOwnerId = Guid.NewGuid(), Priority = 20, TaskId = 7, TaskName = "As-Is-Task4"
                },
                new Models.DataModels.Task()
                {
                    ProjectId = 5, Project = new Models.DataModels.Project()
                    {
                        ProjectName = "test-5", ProjectId = 5
                    }, TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "As-Is-Task5",
                },
                new Models.DataModels.Task()
                {
                    ProjectId = 6, Project = new Models.DataModels.Project()
                    {
                        ProjectName = "test-6", ProjectId = 6
                    }, TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "As-Is-Task6",
                },
                new Models.DataModels.Task()
                {
                    ProjectId = 7, Project = new Models.DataModels.Project()
                    {
                        ProjectName = "test-7", ProjectId = 7
                    }, TaskOwnerId = Guid.NewGuid(), Priority = 30, TaskId = 5, TaskName = "As-Is-Task7",
                },
            }.AsEnumerable();

            // Act
            var actualDataModelResult = tasksList.AsDataModel(testDataModelList);

            // Assert
            Assert.Equal(testDataModelList.Select(t => t.ProjectId), actualDataModelResult.Select(t => t.ProjectId));
            Assert.Equal(tasksList.Select(t => t.TaskName), actualDataModelResult.Select(t => t.TaskName));
        }
コード例 #4
0
 public Models.ViewModels.Task CreateTask(Models.ViewModels.Task task)
 {
     return(taskRepository.Create(task.AsDataModel()).AsViewModel());
 }