public async Task CreateConversationAsync_WithBodyNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new ConversationEndpoint(client); var exception = await Record.ExceptionAsync( async () => await endpoint.CreateConversationAsync("Recipient", null).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); }
public async Task CreateConversationAsync_True() { var mockUrl = "https://api.imgur.com/3/conversations/Bob"; var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockConversationEndpointResponses.CreateConversation) }; var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new ConversationEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse))); var created = await endpoint.CreateConversationAsync("Bob", "Hello World!").ConfigureAwait(false); Assert.True(created); }
public async Task ReportSenderAsync_WithUsernameNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new ConversationEndpoint(client); var exception = await Record.ExceptionAsync( async () => await endpoint.ReportSenderAsync(null).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); }
public async Task GetConversationsAsync_WithOAuth2TokenNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new ConversationEndpoint(client); var exception = await Record.ExceptionAsync( async () => await endpoint.GetConversationsAsync().ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); }
public async Task GetConversationsAsync_True() { var mockUrl = "https://api.imgur.com/3/conversations"; var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockConversationEndpointResponses.GetConversations) }; var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new ConversationEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse))); var conversations = await endpoint.GetConversationsAsync().ConfigureAwait(false); Assert.NotNull(conversations); Assert.True(conversations.Any()); }
public async Task GetConversationAsync_True() { var mockUrl = "https://api.imgur.com/3/conversations/1234/1/0"; var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockConversationEndpointResponses.GetConversation) }; var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new ConversationEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse))); var conversation = await endpoint.GetConversationAsync("1234").ConfigureAwait(false); Assert.NotNull(conversation); Assert.Equal(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(1451010592), conversation.DateTime); Assert.Equal(false, conversation.Done); Assert.Equal(34361981, conversation.Id); Assert.Equal("Test 2", conversation.LastMessagePreview); Assert.Equal(3, conversation.Messages.Count()); Assert.Equal(3, conversation.MessageCount); Assert.Equal(2, conversation.Page); Assert.Equal("Bob", conversation.WithAccount); Assert.Equal(1198054, conversation.WithAccountId); Assert.True(conversation.Messages.Any()); }