GetNotificationsAsync() public method

Returns all of the notifications for the user. OAuth authentication required.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from an Imgur endpoint. Thrown when an error is found in a response from a Mashape endpoint.
public GetNotificationsAsync ( bool newNotifications = true ) : Task
newNotifications bool false for all notifications, true for only non-viewed notification. Default is true.
return Task
コード例 #1
0
        public async Task GetNotificationsAsync_NotNull()
        {
            var mockUrl = "https://api.imgur.com/3/notification?new=false";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockNotificationEndpointResponses.GetNotifications)
            };

            var client = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new NotificationEndpoint(client,
                new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var notifications = await endpoint.GetNotificationsAsync(false).ConfigureAwait(false);

            Assert.NotNull(notifications);
            Assert.NotNull(notifications.Messages);
            Assert.NotNull(notifications.Replies);
        }
コード例 #2
0
        public async Task GetNotificationsAsync_OAuth2Null_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new NotificationEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.GetNotificationsAsync().ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }