public async Task GetProfileAsync_ValidContent_Equal() { var mockHttpMessageHandler = new MockHttpMessageHandler(); var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockPersonalityInsightsResponses.MockResponse) }; mockHttpMessageHandler.AddResponseMessage(ServiceUrl, mockResponse); var httpCLient = new HttpClient(mockHttpMessageHandler); var service = new PersonalityInsightsService("username", "password", httpCLient, new WatsonSettings()); var profile = await service.GetProfileAsync("Hello world").ConfigureAwait(false); Assert.NotNull(profile); }
public async Task GetProfileAsJsonAsync_ValidContentWithFormatting_Equal() { var mockHttpMessageHandler = new MockHttpMessageHandler(); var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockPersonalityInsightsResponses.MockResponse) }; mockHttpMessageHandler.AddResponseMessage(ServiceUrl, mockResponse); var httpCLient = new HttpClient(mockHttpMessageHandler); var service = new PersonalityInsightsService("username", "password", httpCLient, new WatsonSettings()); var profile = await service.GetProfileAsJsonAsync("Hello world", Formatting.Indented).ConfigureAwait(false); var mockResponseObj = JsonConvert.DeserializeObject(profile); var mockResponseJson = JsonConvert.SerializeObject(mockResponseObj, Formatting.Indented); Assert.Equal(mockResponseJson, profile); }
public async Task GetProfileAsCsvAsync_ValidOptionsAndIncludeRawAndHeaders_Equal() { var mockHttpMessageHandler = new MockHttpMessageHandler(); var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockPersonalityInsightsResponses.MockStringResponseWithHeaders) }; mockHttpMessageHandler.AddResponseMessage($"{ServiceUrl}?include_raw=true&headers=true", mockResponse); var httpCLient = new HttpClient(mockHttpMessageHandler); var options = new ProfileOptions("bob") {IncludeRaw = true, IncludeCsvHeaders = true}; var service = new PersonalityInsightsService("username", "password", httpCLient, new WatsonSettings()); var profile = await service.GetProfileAsCsvAsync(options).ConfigureAwait(false); Assert.NotNull(profile); Assert.Equal(MockPersonalityInsightsResponses.MockStringResponseWithHeaders, profile); }