Пример #1
0
        public void RegisterUpdateSettingsAndDeleteUser_Success()
        {
            var todoistTokenlessClient = TodoistClientFactory.CreateTokenlessClient();
            var userBase = new UserBase(Guid.NewGuid().ToString("N") + "@example.com", "test user", "Pa$$W@rd");
            var userInfo = todoistTokenlessClient.RegisterUserAsync(userBase).Result;

            Assert.NotNull(userInfo);

#pragma warning disable CS0618 // Type or member is obsolete
            var todoistClient = todoistTokenlessClient.LoginAsync(userBase.Email, userBase.Password).Result;
#pragma warning restore CS0618 // Type or member is obsolete

            todoistClient.Users.UpdateNotificationSettingsAsync(
                NotificationType.ItemCompleted,
                NotificationService.Email,
                true);
            todoistClient.Users.UpdateKarmaGoalsAsync(new KarmaGoals()
            {
                KarmaDisabled = true
            })
            .Wait();
            todoistClient.Users.UpdateAsync(userInfo)
            .Wait();

            todoistClient.Users.DeleteAsync(userBase.Password, "test");

            todoistClient.Dispose();
        }
Пример #2
0
        public void CreateItemCompleteGetCloseAsync_Success()
        {
            var client = TodoistClientFactory.Create();

            var transaction = client.CreateTransaction();

            var item = new Item("temp task");

            transaction.Items.AddAsync(item).Wait();
            transaction.Notes.AddToItemAsync(new Note("test note"), item.Id).Wait();
            transaction.Items.CloseAsync(item.Id).Wait();

            transaction.CommitAsync().Wait();

            var completedTasks =
                client.Items.GetCompletedAsync(
                    new ItemFilter()
            {
                AnnotateNotes = true, Limit = 5, Since = DateTime.Today.AddDays(-1)
            }).Result;

            Assert.True(completedTasks.Items.Count > 0);

            client.Items.DeleteAsync(item.Id).Wait();
        }
Пример #3
0
        public void CreateDelete_Success()
        {
            var client = TodoistClientFactory.Create();

            var transaction = client.CreateTransaction();

            var itemId     = transaction.Items.AddAsync(new Item("Temp")).Result;
            var reminderId =
                transaction.Reminders.AddAsync(new Reminder(itemId)
            {
                DueDateUtc = DateTime.UtcNow.AddDays(1)
            }).Result;

            transaction.CommitAsync().Wait();

            var reminders = client.Reminders.GetAsync().Result;

            Assert.True(reminders.Count() > 0);

            var reminderInfo = client.Reminders.GetAsync(reminderId).Result;

            Assert.True(reminderInfo != null);

            client.Reminders.DeleteAsync(reminderInfo.Reminder.Id).Wait();
            client.Items.DeleteAsync(itemId);
        }
Пример #4
0
        public void MoveItemsToProject_Success()
        {
            var client = TodoistClientFactory.Create();

            var item = new Item("demo task");

            client.Items.AddAsync(item).Wait();

            item.DateString = "every fri";
            client.Items.UpdateAsync(item).Wait();

            var project = new Project(Guid.NewGuid().ToString());

            client.Projects.AddAsync(project);

            var itemInfo = client.Items.GetAsync(item.Id).Result;

            Assert.True(project.Id != itemInfo.Project.Id);

            client.Items.MoveToProjectAsync(project.Id, itemInfo.Item).Wait();
            itemInfo = client.Items.GetAsync(item.Id).Result;

            Assert.True(project.Id == itemInfo.Project.Id);

            client.Projects.DeleteAsync(project.Id).Wait();
        }
Пример #5
0
        public void AddNoteToNewProjectAttachFileAndDeleteIt_Success()
        {
            var client = TodoistClientFactory.Create();

            var project = new Project(Guid.NewGuid().ToString());

            client.Projects.AddAsync(project).Wait();

            var note     = new Note("Hello");
            var fileName = "test.txt";
            var upload   = client.Uploads.UploadAsync(fileName, Encoding.UTF8.GetBytes("hello")).Result;

            note.FileAttachment = upload;

            client.Notes.AddToProjectAsync(note, project.Id.PersistentId).Wait();

            var projectInfo  = client.Projects.GetAsync(project.Id).Result;
            var attachedNote = projectInfo.Notes.FirstOrDefault();

            Assert.True(attachedNote != null);
            Assert.True(attachedNote.FileAttachment.FileName == fileName);

            client.Notes.DeleteAsync(attachedNote.Id).Wait();

            projectInfo = client.Projects.GetAsync(project.Id).Result;
            Assert.True(!projectInfo.Notes.Any());

            client.Projects.DeleteAsync(project.Id).Wait();
        }
Пример #6
0
        public void CreateProjectAndCreateNote_Success()
        {
            var client = TodoistClientFactory.Create();

            var transaction = client.CreateTransaction();

            var project   = new Project(Guid.NewGuid().ToString());
            var projectId = transaction.Project.AddAsync(project).Result;
            var note      = new Note("Demo note");

            transaction.Notes.AddToProjectAsync(note, projectId).Wait();

            transaction.CommitAsync().Wait();

            var projectInfo = client.Projects.GetAsync(project.Id).Result;

            Assert.True(projectInfo.Notes.Count > 0);

            var deleteTransaction = client.CreateTransaction();

            deleteTransaction.Notes.DeleteAsync(note.Id).Wait();
            deleteTransaction.Project.DeleteAsync(project.Id).Wait();

            deleteTransaction.CommitAsync().Wait();
        }
Пример #7
0
        public void CreateUpdateDelete_Success()
        {
            var client = TodoistClientFactory.Create();

            var filter = new Filter(Guid.NewGuid().ToString(), "today");

            client.Filters.AddAsync(filter).Wait();

            var filters = client.Filters.GetAsync().Result;

            Assert.Contains(filters, f => f.Name == filter.Name);

            filter.Query = "test";
            client.Filters.UpdateAsync(filter)
            .Wait();
            var filterOrder = 2;

            client.Filters.UpdateOrderAsync(new OrderEntry(filter.Id, filterOrder)).Wait();

            var filterInfo = client.Filters.GetAsync(filter.Id).Result;

            Assert.Equal(filter.Query, filterInfo.Filter.Query);
            Assert.Equal(filterOrder, filterInfo.Filter.ItemOrder);

            client.Filters.DeleteAsync(filter.Id).Wait();
        }
Пример #8
0
        public void GetBackups_Success()
        {
            var client = TodoistClientFactory.Create();

            var backups = client.Backups.GetAsync().Result;

            Assert.True(backups.Count() > 0);
        }
Пример #9
0
        public void GetActivity_HasEntries()
        {
            var client = TodoistClientFactory.Create();

            var logEntries = client.Activity.GetAsync(new LogFilter() { Limit = 50 }).Result;

            Assert.True(logEntries.Any());
        }
Пример #10
0
        public void GetNotification_Success()
        {
            var client = TodoistClientFactory.Create();

            var notifications = client.Notifications.GetAsync().Result;

            Assert.True(notifications.Any());
        }
Пример #11
0
        public void ExportAsShareableUrl_Success()
        {
            var client = TodoistClientFactory.Create();

            var firstProject = client.Projects.GetAsync().Result.First();
            var template     = client.Templates.ExportAsShareableUrlAsync(firstProject.Id).Result;

            Assert.True(!string.IsNullOrEmpty(template.FileUrl));
        }
Пример #12
0
        public void GetCurrentAsync_Success()
        {
            var client = TodoistClientFactory.Create();

            var user = client.Users.GetCurrentAsync().Result;

            Assert.NotNull(user);
            Assert.True(user.Id > 0);
        }
Пример #13
0
        public void GetActivity_HasEntries()
        {
            var client = TodoistClientFactory.Create();

            var logEntries = client.Activity.GetAsync(new LogFilter()
            {
                Limit = 50
            }).Result.Events;

            Assert.NotEmpty(logEntries);
        }
Пример #14
0
        public void UpdateOrders_Success()
        {
            var client = TodoistClientFactory.Create();

            var item = client.Items.QuickAddAsync(new QuickAddItem("Demo task every fri")).Result;

            client.Items.UpdateMultipleOrdersIndentsAsync(new OrderIndentEntry(item.Id, 1, 1)).Wait();
            client.Items.UpdateDayOrdersAsync(new OrderEntry(item.Id, 2));

            client.Items.DeleteAsync(item.Id).Wait();
        }
Пример #15
0
        public void GetActivityWithEventObjectFilter_HasEntries()
        {
            var client = TodoistClientFactory.Create();

            var logFilter = new LogFilter();
            logFilter.ObjectEventTypes.Add(new ObjectEventTypes() { ObjectType = "project" });

            var logEntries = client.Activity.GetAsync(logFilter).Result;

            Assert.True(logEntries.Any());
        }
Пример #16
0
        public void GetFilterInfo_Success()
        {
            var client = TodoistClientFactory.Create();

            var filters = client.Filters.GetAsync().Result;

            Assert.True(filters.Any());

            var result = client.Filters.GetAsync(filters.First().Id).Result;

            Assert.True(result != null);
        }
Пример #17
0
        public void GetOrCreateAsyncDisable_NewProject_Success()
        {
            var client = TodoistClientFactory.Create();

            var projectId = client.Projects.AddAsync(new Project(Guid.NewGuid().ToString())).Result;
            var emailInfo = client.Emails.GetOrCreateAsync(ObjectType.Project, projectId).Result;

            Assert.NotNull(emailInfo);
            Assert.NotNull(emailInfo.Email);

            client.Emails.DisableAsync(ObjectType.Project, projectId).Wait();
            client.Projects.DeleteAsync(projectId).Wait();
        }
Пример #18
0
        public void CreateItem_InvalidProjectId_ThrowsException()
        {
            var client = TodoistClientFactory.Create();
            var item   = new Item("bad task", 123);

            var aggregateException = Assert.ThrowsAsync <AggregateException>(
                async() =>
            {
                await client.Items.AddAsync(item);
            }).Result;

            Assert.IsType <TodoistException>(aggregateException.InnerExceptions.First());
        }
Пример #19
0
        public void QuickAddAsync_Success()
        {
            var client = TodoistClientFactory.Create();

            var item = client.Items.QuickAddAsync(new QuickAddItem("Demo task every fri")).Result;

            Assert.NotNull(item);

            client.Items.CompleteRecurringAsync(new CompleteRecurringItemArgument(item.Id, new DueDate(DateTime.UtcNow.AddMonths(1)))).Wait();
            client.Items.CompleteRecurringAsync(item.Id).Wait();

            client.Items.DeleteAsync(item.Id).Wait();
        }
Пример #20
0
        public void UpdateOrders_Success()
        {
            var client = TodoistClientFactory.Create();

            var item = client.Items.QuickAddAsync(new QuickAddItem("Demo task every fri")).Result;

            var firstProject = client.Projects.GetAsync().Result.First();

            client.Items.MoveAsync(ItemMoveArgument.CreateMoveToProject(item.Id, firstProject.Id)).Wait();
            client.Items.UpdateDayOrdersAsync(new OrderEntry(item.Id, 2));

            client.Items.DeleteAsync(item.Id).Wait();
        }
Пример #21
0
        public void ShareProjectAndUnshare_NewUser_Success()
        {
            var client = TodoistClientFactory.Create();

            var projectId = client.Projects.AddAsync(new Project(Guid.NewGuid().ToString())).Result;

            var email = "*****@*****.**";

            client.Sharing.ShareProjectAsync(projectId, email).Wait();

            client.Sharing.DeleteCollaboratorAsync(projectId, email).Wait();

            client.Projects.DeleteAsync(projectId).Wait();
        }
Пример #22
0
        public async Task Reorder_Success()
        {
            var client = TodoistClientFactory.Create();

            var projectId = await client.Projects.AddAsync(new Project("test"));

            var firstId = await client.Sections.AddAsync(new Section("test", projectId));

            var secondId = await client.Sections.AddAsync(new Section("test2", projectId));

            await client.Sections.ReorderAsync(new SectionOrderEntry(secondId, 1), new SectionOrderEntry(firstId, 2));

            await client.Projects.DeleteAsync(projectId);
        }
Пример #23
0
        public void CreateUpdateOrderGetInfoDelete_Success()
        {
            var client = TodoistClientFactory.Create();

            var label = new Label("Test label");

            client.Labels.AddAsync(label).Wait();

            client.Labels.UpdateOrderAsync(new OrderEntry(label.Id, 1)).Wait();

            var labelInfo = client.Labels.GetAsync(label.Id).Result;

            client.Labels.DeleteAsync(labelInfo.Label.Id).Wait();
        }
Пример #24
0
        public void CreateItemGetByIdAndDelete_Success()
        {
            var client = TodoistClientFactory.Create();

            var item = new Item("demo task");

            client.Items.AddAsync(item).Wait();

            var itemInfo = client.Items.GetAsync(item.Id).Result;

            Assert.True(itemInfo.Item.Content == item.Content);

            client.Items.DeleteAsync(item.Id).Wait();
        }
Пример #25
0
        public void CreateGetDeleteAsync_Success()
        {
            var client = TodoistClientFactory.Create();

            var fileName = $"{Guid.NewGuid().ToString()}.txt";
            var upload   = client.Uploads.UploadAsync(fileName, Encoding.UTF8.GetBytes("hello")).Result;

            var allUploads = client.Uploads.GetAsync().Result;

            Assert.Contains(allUploads, u => u.FileUrl == upload.FileUrl);

            client.Uploads.DeleteAsync(upload.FileUrl).Wait();

            allUploads = client.Uploads.GetAsync().Result;
            Assert.True(allUploads.All(u => u.FileUrl != upload.FileUrl));
        }
Пример #26
0
        public void CreateNewItem_DueDateIsLocal_DueDateNotChanged()
        {
            var client = TodoistClientFactory.Create();

            var item = new Item("New task")
            {
                DueDateUtc = DateTime.Now.AddYears(1).Date
            };
            var taskId = client.Items.AddAsync(item).Result;

            var itemInfo = client.Items.GetAsync(taskId).Result;

            Assert.Equal(item.DueDateUtc.Value, itemInfo.Item.DueDateUtc.Value.ToLocalTime());

            client.Items.DeleteAsync(item.Id).Wait();
        }
Пример #27
0
        public void ExportAndImportTemplate_Success()
        {
            var client = TodoistClientFactory.Create();

            var firstProject = client.Projects.GetAsync().Result.First();

            var template = client.Templates.ExportAsFileAsync(firstProject.Id).Result;

            var tempProject = new Project(Guid.NewGuid().ToString());

            client.Projects.AddAsync(tempProject).Wait();

            client.Templates.ImportIntoProjectAsync(tempProject.Id, Encoding.UTF8.GetBytes(template)).Wait();

            client.Projects.DeleteAsync(tempProject.Id);
        }
Пример #28
0
        public void AddNoteToNewProjectAndUpdateIt_Success()
        {
            var todoistClient = TodoistClientFactory.Create();

            var project = new Project(Guid.NewGuid().ToString());

            todoistClient.Projects.AddAsync(project).Wait();

            var note = new Note("Hello");

            todoistClient.Notes.AddToProjectAsync(note, project.Id.PersistentId).Wait();

            note.Content = "Updated";
            todoistClient.Notes.UpdateAsync(note).Wait();

            todoistClient.Projects.DeleteAsync(project.Id).Wait();
        }
Пример #29
0
        public void CreateProjectAndGetProjectData_Success()
        {
            var client = TodoistClientFactory.Create();

            var transaction = client.CreateTransaction();

            var projectId = transaction.Project.AddAsync(new Project("Test")).Result;

            transaction.Items.AddAsync(new Item("Test task", projectId)).Wait();

            transaction.CommitAsync().Wait();

            var projectData = client.Projects.GetDataAsync(projectId).Result;

            Assert.Equal(1, projectData.Items.Count);

            client.Projects.DeleteAsync(projectId).Wait();
        }
Пример #30
0
        public void AddNoteGetByIdAndDelete_Success()
        {
            var todoistClient = TodoistClientFactory.Create();

            var project = new Project(Guid.NewGuid().ToString());

            todoistClient.Projects.AddAsync(project).Wait();

            var note = new Note("Hello");

            todoistClient.Notes.AddToProjectAsync(note, project.Id.PersistentId).Wait();

            var noteInfo = todoistClient.Notes.GetAsync(note.Id).Result;

            Assert.True(noteInfo.Note.Content == note.Content);

            todoistClient.Projects.DeleteAsync(project.Id).Wait();
        }