Ejemplo n.º 1
0
        public async Task NotificationTestAsync()
        {
            var conf = new BacklogJpConfigure(generalConfig.SpaceKey);

            conf.ApiKey = generalConfig.ApiKey2;
            var client2 = new BacklogClientFactory(conf).NewClient();

            var issueTypes = await client.GetIssueTypesAsync(projectId);

            var issue = await client2.CreateIssueAsync(new CreateIssueParams(projectId, "NotificationTestIssue", issueTypes.First().Id, IssuePriorityType.High)
            {
                NotifiedUserIds = new[] { ownUser.Id }
            });

            var count = await client.GetNotificationCountAsync(new GetNotificationCountParams());

            Assert.IsTrue(count > 0);
            await client.GetNotificationCountAsync(new GetNotificationCountParams()
            {
                AlreadyRead = true
            });

            await client.GetNotificationCountAsync(new GetNotificationCountParams()
            {
                ResourceAlreadyRead = true
            });

            await client.GetNotificationsAsync(new QueryParams()
            {
                Count = 100, MinId = 1, MaxId = int.MaxValue, Order = Order.Desc
            });

            var notifications = await client.GetNotificationsAsync();

            Assert.IsTrue(notifications.Any(x => x?.Issue.Id == issue.Id));

            var notification = notifications.First(x => x?.Issue.Id == issue.Id);
            await client.MarkAsReadNotificationAsync(notification.Id);

            await client.ResetNotificationCountAsync();

            await client.DeleteIssueAsync(issue.Id);
        }