Пример #1
0
        public async Task TaskControllerAddAndGetTest()
        {
            var uDAL            = new DemoUsersDAL();
            var tBLL            = new DemoTasksBLL(uDAL);
            var tasksController = new TasksController(tBLL);

            var result = await tasksController.GetAll();

            var okObjectResult = Assert.IsType <OkObjectResult>(result);
            var taskList       = Assert.IsType <List <TasklifyTask> >(okObjectResult.Value);

            Assert.Empty(taskList);

            result = await tasksController.Add(new TasklifyTask(1, "summary", "description"));

            okObjectResult = Assert.IsType <OkObjectResult>(result);
            var value = Assert.IsType <TasklifyTask>(okObjectResult.Value);

            Assert.Equal(1, value.Id);
            Assert.Equal("summary", value.Summary);
            Assert.Equal("description", value.Description);

            result = await tasksController.Add(new TasklifyTask(1, "", "description"));

            var objectResult = Assert.IsType <BadRequestObjectResult>(result);

            Assert.Equal(400, objectResult.StatusCode);
            var errorString = Assert.IsType <String>(objectResult.Value);

            Assert.Equal("Task summary cannot be empty or all whitespace.", errorString);

            await tasksController.Add(new TasklifyTask(2, "summary2", "description2"));

            result = await tasksController.GetAll();

            okObjectResult = Assert.IsType <OkObjectResult>(result);
            taskList       = Assert.IsType <List <TasklifyTask> >(okObjectResult.Value);

            Assert.Collection(taskList.OrderBy(user => user.Id),
                              task => {
                Assert.Equal(1, task.Id);
                Assert.Equal("summary", task.Summary);
                Assert.Equal("description", task.Description);
            },
                              task => {
                Assert.Equal(2, task.Id);
                Assert.Equal("summary2", task.Summary);
                Assert.Equal("description2", task.Description);
            });
        }
Пример #2
0
        private void ThisAddIn_Startup(object sender, EventArgs e)
        {
            // get the explorers.
            _explorers = Application.Explorers;

            // get all the folders.
            _folders = Application.Session.DefaultStore.GetRootFolder().Folders;

            // create all the required values.
            Create();

            // new email arrives.
            Application.NewMailEx += Application_NewMailEx;

            // start all the values
            Start();

            // do we want to check unprocessed emails?
            if (TheEngine.Options.CheckUnProcessedEmailsOnStartUp)
            {
                TasksController.Add(ParseUnprocessedEmailsAsync());
            }

            // log the version
            LogStartupInformation();
        }
Пример #3
0
        public async Task TaskControllerDeleteUserTest()
        {
            var uDAL            = new DemoUsersDAL();
            var tBLL            = new DemoTasksBLL(uDAL);
            var tasksController = new TasksController(tBLL);

            var result = await tasksController.DeleteById(1);

            var objectResult = Assert.IsType <StatusCodeResult>(result);

            Assert.Equal(403, objectResult.StatusCode);

            await tasksController.Add(new TasklifyTask(1, "summary", "description"));

            result = await tasksController.DeleteById(1);

            Assert.IsType <NoContentResult>(result);

            result = await tasksController.GetAll();

            var okObjectResult = Assert.IsType <OkObjectResult>(result);
            var taskList       = Assert.IsType <List <TasklifyTask> >(okObjectResult.Value);

            Assert.Empty(taskList);
        }
Пример #4
0
        private void Start()
        {
            _cts = new CancellationTokenSource();

            TheMailProcessor.Start(_cts.Token);

            // look for item moves.
            TasksController.Add(Task.Run(() => MonitorItemMove()));
        }
Пример #5
0
 public void ParseFolders(IList <Outlook.MAPIFolder> folders)
 {
     // then reparse them all
     foreach (var mapiFolder in folders)
     {
         var unProcessedFolders = new UnProcessedFolders("Parse folder", TheMailProcessor, TheEngine.Logger);
         TasksController.Add(unProcessedFolders.ProcessAsync(mapiFolder, (int)TheEngine.Options.NumberOfItemsToParse, false, _cts.Token));
     }
 }
Пример #6
0
        public async Task TaskControllerUpdateTaskTest()
        {
            var uDAL            = new DemoUsersDAL();
            var tBLL            = new DemoTasksBLL(uDAL);
            var tasksController = new TasksController(tBLL);

            var result = await tasksController.UpdateById(1, new TasklifyTask(1, "summary", "description"));

            var objectResult = Assert.IsType <StatusCodeResult>(result);

            Assert.Equal(403, objectResult.StatusCode);

            result = await tasksController.PatchById(1, new JsonPatchDocument <TasklifyTask>());

            objectResult = Assert.IsType <StatusCodeResult>(result);
            Assert.Equal(403, objectResult.StatusCode);

            await tasksController.Add(new TasklifyTask(1, "summary", "description"));

            result = await tasksController.UpdateById(1, new TasklifyTask(1, "", "description"));

            var errorObject = Assert.IsType <BadRequestObjectResult>(result);

            Assert.Equal(400, errorObject.StatusCode);

            var patchDocument = new JsonPatchDocument <TasklifyTask>();

            patchDocument.Replace(task => task.Summary, "");
            result = await tasksController.PatchById(1, patchDocument);

            errorObject = Assert.IsType <BadRequestObjectResult>(result);
            Assert.Equal(400, errorObject.StatusCode);

            var errorString = Assert.IsType <String>(errorObject.Value);

            Assert.Equal("Task summary cannot be empty or all whitespace.", errorString);

            result = await tasksController.UpdateById(1, new TasklifyTask(1, "newsummary", "description"));

            var okObjectResult = Assert.IsType <OkObjectResult>(result);
            var task           = Assert.IsType <TasklifyTask>(okObjectResult.Value);

            Assert.Equal(1, task.Id);
            Assert.Equal("newsummary", task.Summary);
            Assert.Equal("description", task.Description);

            patchDocument = new JsonPatchDocument <TasklifyTask>();
            patchDocument.Replace(task => task.Summary, "updatedsummary");
            result = await tasksController.PatchById(1, patchDocument);

            okObjectResult = Assert.IsType <OkObjectResult>(result);
            task           = Assert.IsType <TasklifyTask>(okObjectResult.Value);
            Assert.Equal(1, task.Id);
            Assert.Equal("updatedsummary", task.Summary);
            Assert.Equal("description", task.Description);
        }
Пример #7
0
        public void AddTasks_Test_ReturnSuccess()
        {
            var tasksAdd = new Tasks {
                ID = 5, AssignedToUserID = 1, ProjectID = 1, Detail = "Test Task 1", CreatedOn = DateTime.Now, Status = ProjectManagement.Entities.Enums.TaskStatus.New
            };

            mockObject.Setup(m => m.Add(tasksAdd)).Returns(() => Task <Tasks> .FromResult(tasksAdd));
            TasksController tasksController = new TasksController(mockObject.Object);
            var             result          = tasksController.Add(tasksAdd);

            Assert.NotNull(result);
        }
Пример #8
0
 public override void StartPhase()
 {
     base.StartPhase();
     tasksController = TasksController.GetInstance();
     task            = tasksController?.Add(info);
 }
 private void buttonAddTask_Click(object sender, EventArgs e)
 {
     _ctrlTasks.Add(Int32.Parse(textBoxIDTask.Text), textBoxDescription.Text, Int32.Parse(textBoxDuration.Text));
     CleanTextBox();
 }
Пример #10
0
 public void AddActiveTask()
 {
     tasksController.Add("Активное упражнение", TaskElement.TaskState.Active);
 }
Пример #11
0
 private void Application_NewMailEx(string entryIdItem)
 {
     //  just call the async version of this
     TasksController.Add(Application_NewMailExAsync(entryIdItem));
 }