public async Task GetProfileAsJsonAsync_WithString_IsNotNull() { var content = File.ReadAllText("SampleContent1.txt"); var service = new PersonalityInsightsService(Settings.Username, Settings.Password); var profile = await service.GetProfileAsJsonAsync(content).ConfigureAwait(false); Assert.NotNull(profile); Assert.True(profile.StartsWith("{")); Assert.True(profile.EndsWith("}")); }
public async Task GetProfileAsJsonAsync_NullOptions_ThrowsArgumentNullException() { var service = new PersonalityInsightsService("username", "password", new WatsonSettings()); var exception = await Record.ExceptionAsync( async () => await service.GetProfileAsJsonAsync(options: null).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); }
public async Task GetProfileAsJsonAsync_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.GetProfileAsJsonAsync("Hello world").ConfigureAwait(false); var mockResponseObj = JsonConvert.DeserializeObject(profile); var mockResponseJson = JsonConvert.SerializeObject(mockResponseObj); Assert.Equal(mockResponseJson, profile); }
public async Task GetProfileAsJsonAsync_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.GetProfileAsJsonAsync(options).ConfigureAwait(false); Assert.NotNull(profile); Assert.True(profile.StartsWith("{")); Assert.True(profile.EndsWith("}")); }