コード例 #1
0
        public void AddTask()
        {
            TaskData lstTaskData = new TaskData()
            {
                TaskID     = 1,
                ParentID   = 1,
                ProjectID  = 1,
                UserID     = 1,
                Task       = "First Task",
                ParentTask = "Parent Task 1",
                Priority   = 1,
                EmployeeID = "369470",
                StartDate  = DateTime.Now,
                EndDate    = DateTime.Now.AddDays(10),
                Status     = "Active",
                Project    = "Test Project"
            };
            var controller = new ProjectController()
            {
                Request       = new System.Net.Http.HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            Assert.AreEqual("OK", controller.AddTask(lstTaskData).StatusCode.ToString());
        }
コード例 #2
0
        public void Test_C_Post()
        {
            Task item = new Task()
            {
                TaskId = 1000, ParentId = 1, ProjectId = 1003, UserId = 2, TaskName = "UnitAPITestTask", ParentTask = "Task 10", Priority = 2, SDate = DateTime.Now, EDate = DateTime.Now, Status = "Started", TaskEndFlag = true
            };
            //Task item = new Task() { TaskId = 100, TaskName = "TestTask", ParentTask = "Task11", Priority = 2, SDate = DateTime.Now, EDate = DateTime.Now, TaskEndFlag = true };
            ProjectController obj = new ProjectController();
            var contentResult     = obj.AddTask(item) as OkNegotiatedContentResult <string>;

            Assert.IsNotNull(contentResult);
        }
コード例 #3
0
        public async Task AddTaskTest()
        {
            var taskAdd = new TaskAdd
            {
                EndDate         = DateTime.Today.AddDays(2),
                ParentTaskId    = "P/1-1",
                Priority        = 1,
                ProjectId       = "P/1",
                StartDate       = DateTime.Today,
                TaskDescription = "Task1",
                TaskOwnerId     = "Usr/1"
            };
            var projectService = new Mock <IProjTaskService>();

            projectService.Setup(ser => ser.AddTask(It.IsAny <TaskAdd>()))
            .Returns(Task.FromResult(new Tuple <bool, string>(true, "P/1-1")));
            var logger            = createLogger();
            var projectController = new ProjectController(projectService.Object, logger);
            var actionResult      = (await projectController.AddTask(taskAdd)).Result as CreatedResult;

            Assert.NotNull(actionResult);
            Assert.Equal(201, actionResult.StatusCode);
        }