public async Task GetProfileAsCsvAsync_NullContent_ThrowsArgumentNullException() { var service = new PersonalityInsightsService("username", "password", new WatsonSettings()); var exception = await Record.ExceptionAsync( async () => await service.GetProfileAsCsvAsync(content: null).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); }
public async Task GetProfileAsCsvAsync_WithContentItems_IsNotNull() { var content1 = File.ReadAllText("SampleContent1.txt"); var content2 = File.ReadAllText("SampleContent2.txt"); var service = new PersonalityInsightsService(Settings.Username, Settings.Password); var contentItems = new List<ContentItem> { new ContentItem(content1), new ContentItem(content2) }; var content = new Content(contentItems); var options = new ProfileOptions(content); var profile = await service.GetProfileAsCsvAsync(options).ConfigureAwait(false); Assert.False(string.IsNullOrWhiteSpace(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); }
public async Task GetProfileAsCsvAsync_WithOptions_IsNotNull() { var content = File.ReadAllText("SampleContent1.txt"); var service = new PersonalityInsightsService(Settings.Username, Settings.Password); var options = new ProfileOptions(content) {IncludeRaw = true}; var profile = await service.GetProfileAsCsvAsync(options).ConfigureAwait(false); Assert.False(string.IsNullOrWhiteSpace(profile)); }
public async Task GetProfileAsCsvAsync_ValidContent_Equal() { var mockHttpMessageHandler = new MockHttpMessageHandler(); var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockPersonalityInsightsResponses.MockStringResponse) }; mockHttpMessageHandler.AddResponseMessage(ServiceUrl, mockResponse); var httpCLient = new HttpClient(mockHttpMessageHandler); var service = new PersonalityInsightsService("username", "password", httpCLient, new WatsonSettings()); var profile = await service.GetProfileAsCsvAsync("Hello world").ConfigureAwait(false); Assert.NotNull(profile); Assert.Equal(MockPersonalityInsightsResponses.MockStringResponse, profile); }