示例#1
0
        public async Task <bool> DeleteTaskAsync([FromQuery] int taskId)
        {
            TaskModel task             = taskHandler.GetTask(taskId);
            var       deleteTaskResult = taskHandler.DeleteTask(task);
            var       deletePt         = await pth.DeletePlayerTaskAsync(task);

            var deleteGt = gth.DeleteGameTasks(taskId);

            return(deleteTaskResult && deletePt && deleteGt);
        }
示例#2
0
        public async Task <string> GetVmInfoOnTaskForUserAsync(int taskId, int gameId)
        {
            var context = HttpContext.User;
            var user    = await userHandler.GetUserByEmail(HttpContext.User.Identity.Name);

            var bearer = await aapi.GetBearerTokenAsync();

            var game = gameHandler.GetGame(gameId);
            var task = th.GetTask(taskId);

            if (user == null || game == null || task == null)
            {
                return("VARIABLE IS NULL");
            }
            var PlayerTask = await pth.GetPlayerTaskAsync(game, task, user);

            return(await aapi.GetInfoOnVmAsync(bearer, PlayerTask.VmName));
        }
        public void GetTask_Test()
        {
            Task tsk2 = new Task();

            tsk2.TaskName  = "testTask2";
            tsk2.StartDate = DateTime.Now;
            tsk2.EndDate   = DateTime.Now.AddDays(1);
            tsk2.Priority  = 10;
            tsk2.UserId    = 1;
            tsk2.ProjectId = 1;
            tsk2.TaskId    = 6;
            tsk2.ParentId  = 1;
            tsk2.User      = new User();
            tsk2.Project   = new Project();
            tsk2.Parent    = new ParentTask();
            Task tsk3 = new Task();

            tsk3.TaskName  = "testTask3";
            tsk3.StartDate = DateTime.Now;
            tsk3.EndDate   = DateTime.Now.AddDays(1);
            tsk3.Priority  = 10;
            tsk3.UserId    = 1;
            tsk3.ProjectId = 1;
            tsk3.TaskId    = 7;
            tsk3.ParentId  = 1;
            tsk3.User      = new User();
            tsk3.Project   = new Project();
            tsk3.Parent    = new ParentTask();

            var mockRepo = new Mock <ITaskRepository>();

            mockRepo.Setup(p => p.GetTaskById(6)).Returns(tsk2);
            var handler = new TaskHandler(mockRepo.Object);
            var tsk     = handler.GetTask(6);

            mockRepo.Verify(mock => mock.GetTaskById(6), Times.Once());
            Assert.AreEqual(tsk.TaskId, tsk2.TaskId);
            Assert.AreEqual(tsk.TaskName, tsk.TaskName);
        }