Esempio n. 1
0
        public void Constructor_HttpClient()
        {
            PersonalityInsightsService service =
                new PersonalityInsightsService(CreateClient());

            Assert.IsNotNull(service);
        }
        public void ProfileAsCsv()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            PersonalityInsightsService service = new PersonalityInsightsService("2017-10-13", authenticator);

            service.SetServiceUrl("{serviceUrl}");

            Content content = null;

            content = JsonConvert.DeserializeObject <Content>(File.ReadAllText("profile.json"));

            var result = service.ProfileAsCsv(
                content: content,
                contentType: "application/json",
                consumptionPreferences: true,
                rawScores: true,
                csvHeaders: true
                );

            using (FileStream fs = File.Create("output.csv"))
            {
                result.Result.WriteTo(fs);
                fs.Close();
                result.Result.Close();
            }
        }
Esempio n. 3
0
        public void Constructor_With_UserName_Password()
        {
            PersonalityInsightsService service =
                new PersonalityInsightsService("username", "password", "versionDate");

            Assert.IsNotNull(service);
        }
        public void Profile()
        {
            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = url
            };

            PersonalityInsightsService service = new PersonalityInsightsService(tokenOptions, versionDate);

            Content content = new Content()
            {
                ContentItems = new List <ContentItem>()
                {
                    new ContentItem()
                    {
                        Contenttype = ContentItem.ContenttypeEnumValue.TEXT_PLAIN,
                        Language    = ContentItem.LanguageEnumValue.EN,
                        Content     = contentToProfile
                    }
                }
            };

            var result = service.Profile(
                content: content,
                contentType: "text/plain",
                contentLanguage: "en",
                acceptLanguage: "en",
                rawScores: true,
                consumptionPreferences: true,
                csvHeaders: true
                );

            Console.WriteLine(result.Response);
        }
Esempio n. 5
0
        public void Constructor()
        {
            PersonalityInsightsService service =
                new PersonalityInsightsService();

            Assert.IsNotNull(service);
        }
Esempio n. 6
0
        public static void Main(string[] args)
        {
            var environmentVariable = Environment.GetEnvironmentVariable("VCAP_SERVICES");
            var fileContent         = File.ReadAllText(environmentVariable);
            var vcapServices        = JObject.Parse(fileContent);
            var _username           = vcapServices["personality_insights"][0]["credentials"]["username"];
            var _password           = vcapServices["personality_insights"][0]["credentials"]["password"];

            PersonalityInsightsService _personalityInsights = new PersonalityInsightsService(_username.ToString(), _password.ToString(), "2016-10-20");
            string content = "The IBM Watson™ Personality Insights service provides a Representational State Transfer (REST) Application Programming Interface (API) that enables applications to derive insights from social media, enterprise data, or other digital communications. The service uses linguistic analytics to infer individuals' intrinsic personality characteristics, including Big Five, Needs, and Values, from digital communications such as email, text messages, tweets, and forum posts. The service can automatically infer, from potentially noisy social media, portraits of individuals that reflect their personality characteristics. The service can report consumption preferences based on the results of its analysis, and for JSON content that is timestamped, it can report temporal behavior.";

            //  Test Profile
            ContentListContainer contentListContainer = new ContentListContainer()
            {
                ContentItems = new List <ContentItem>()
                {
                    new ContentItem()
                    {
                        Contenttype = ContentItem.ContenttypeEnum.TEXT_PLAIN,
                        Language    = ContentItem.LanguageEnum.EN,
                        Content     = content
                    }
                }
            };

            var result = _personalityInsights.Profile("text/plain", "application/json", contentListContainer, rawScores: true, consumptionPreferences: true, csvHeaders: true);

            Console.WriteLine(string.Format("Profile result: {0}", result));

            Console.ReadKey();
        }
Esempio n. 7
0
        public void PersonalityInsightsV3WithLoadedCredentials_Success()
        {
            PersonalityInsightsService service = new PersonalityInsightsService();

            Assert.IsTrue(!string.IsNullOrEmpty(service.ApiKey));
            Assert.IsTrue(!string.IsNullOrEmpty(service.Url));
        }
        public void Profile()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            PersonalityInsightsService service = new PersonalityInsightsService("2017-10-13", authenticator);

            service.SetServiceUrl("{serviceUrl}");

            using (FileStream fs = File.OpenRead("profile.json"))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    fs.CopyTo(ms);

                    var result = service.Profile(
                        content: ms,
                        contentType: "application/json",
                        rawScores: true,
                        consumptionPreferences: true
                        );
                    Console.WriteLine(result.Response);
                }
            }
        }
        public void ProfileAsCsv()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            PersonalityInsightsService service = new PersonalityInsightsService("2017-10-13", authenticator);

            service.SetServiceUrl("{serviceUrl}");

            using (FileStream fs = File.OpenRead("profile.json"))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    fs.CopyTo(ms);
                    var result = service.ProfileAsCsv(
                        content: ms,
                        contentType: "application/json",
                        consumptionPreferences: true,
                        rawScores: true,
                        csvHeaders: true
                        );

                    using (FileStream fsOutput = File.Create("output.csv"))
                    {
                        result.Result.WriteTo(fsOutput);
                        fsOutput.Close();
                        result.Result.Close();
                    }
                }
            }
        }
Esempio n. 10
0
        public void Profile()
        {
            IamConfig config = new IamConfig(
                apikey: apikey
                );

            PersonalityInsightsService service = new PersonalityInsightsService(versionDate, config);

            service.SetEndpoint(url);

            Content content = new Content()
            {
                ContentItems = new List <ContentItem>()
                {
                    new ContentItem()
                    {
                        Contenttype = ContentItem.ContenttypeEnumValue.TEXT_PLAIN,
                        Language    = ContentItem.LanguageEnumValue.EN,
                        Content     = contentToProfile
                    }
                }
            };

            var result = service.Profile(
                content: content,
                contentType: "text/plain",
                contentLanguage: "en",
                acceptLanguage: "en",
                rawScores: true,
                consumptionPreferences: true,
                csvHeaders: true
                );

            Console.WriteLine(result.Response);
        }
Esempio n. 11
0
        public void Profile_No_Content()
        {
            PersonalityInsightsService service =
                new PersonalityInsightsService("username", "password", "versionDate");

            service.Profile(null, "contentType");
        }
Esempio n. 12
0
        public void Profle_Catch_Exception()
        {
            IClient client = CreateClient();

            IRequest request = Substitute.For <IRequest>();

            client.PostAsync(Arg.Any <string>())
            .Returns(x =>
            {
                throw new AggregateException(new ServiceResponseException(Substitute.For <IResponse>(),
                                                                          Substitute.For <HttpResponseMessage>(HttpStatusCode.BadRequest),
                                                                          string.Empty));
            });

            //  Test Profile
            Content content = new Content()
            {
                ContentItems = new List <ContentItem>()
                {
                    new ContentItem()
                    {
                        Contenttype = ContentItem.ContenttypeEnum.TEXT_PLAIN,
                        Language    = ContentItem.LanguageEnum.EN,
                        Content     = contentString
                    }
                }
            };

            PersonalityInsightsService service = new PersonalityInsightsService(client);

            service.VersionDate = "versionDate";

            service.Profile(content, "contentType", "application/json");
        }
        public void ProfileAsCsv_Success()
        {
            IClient  client  = Substitute.For <IClient>();
            IRequest request = Substitute.For <IRequest>();

            client.PostAsync(Arg.Any <string>())
            .Returns(request);

            PersonalityInsightsService service = new PersonalityInsightsService(client);
            var versionDate = "versionDate";

            service.Version = versionDate;

            var content                = new MemoryStream();
            var contentType            = "contentType";
            var contentLanguage        = "contentLanguage";
            var acceptLanguage         = "acceptLanguage";
            var rawScores              = false;
            var csvHeaders             = false;
            var consumptionPreferences = false;

            var result = service.ProfileAsCsv(content: content, contentType: contentType, contentLanguage: contentLanguage, acceptLanguage: acceptLanguage, rawScores: rawScores, csvHeaders: csvHeaders, consumptionPreferences: consumptionPreferences);

            JObject bodyObject = new JObject();
            var     json       = JsonConvert.SerializeObject(bodyObject);

            request.Received().WithArgument("version", versionDate);
            //TODO: fix unit test
            //request.Received().WithBodyContent(Arg.Is<StringContent>(x => x.ReadAsStringAsync().Result.Equals(json)));
        }
        public async Task GetProfileAsync_WithString_IsNotNull()
        {
            var content = File.ReadAllText("SampleContent1.txt");

            var service = new PersonalityInsightsService(Settings.Username, Settings.Password);
            var profile = await service.GetProfileAsync(content).ConfigureAwait(false);

            Assert.NotNull(profile);
        }
 /// <summary>
 /// Wrapper Controller Constructor
 /// </summary>
 public PersonalityController()
 {
     IBMId                = "f7de21f9-1eee-4e47-9ff2-1040d6c762cb";
     IBMPassword          = "******";
     _personalityInsights = new PersonalityInsightsService(IBMId, IBMPassword, "2017-10-13");
     twitterCredentials   = new TwitterCredentials(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
     //Auth.SetUserCredentials(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
     //Auth.SetCredentials(twitterCredentials);
 }
        public void ConstructorExternalConfig()
        {
            var apikey = System.Environment.GetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY");

            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY", "apikey");
            PersonalityInsightsService service = Substitute.For <PersonalityInsightsService>("versionDate");

            Assert.IsNotNull(service);
            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY", apikey);
        }
        public async Task GetProfileAsync_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.GetProfileAsync(options).ConfigureAwait(false);

            Assert.NotNull(profile);
        }
        public async Task GetProfileAsync_NullOptions_ThrowsArgumentNullException()
        {
            var service = new PersonalityInsightsService("username", "password", new WatsonSettings());

            var exception =
                await
                    Record.ExceptionAsync(async () => await service.GetProfileAsync(options: null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
        public IEnumerator UnityTestSetup()
        {
            if (service == null)
            {
                service = new PersonalityInsightsService(versionDate);
            }

            while (!service.Authenticator.CanAuthenticate())
            {
                yield return(null);
            }
        }
        private IEnumerator CreateService()
        {
            service = new PersonalityInsightsService("2019-02-18");

            //  Wait for authorization token
            while (!service.Credentials.HasIamTokenData())
            {
                yield return(null);
            }

            Runnable.Run(Examples());
        }
Esempio n. 21
0
        public IEnumerator UnityTestSetup()
        {
            if (service == null)
            {
                service = new PersonalityInsightsService(versionDate);
            }

            while (!service.Credentials.HasIamTokenData())
            {
                yield return(null);
            }
        }
        public void ConstructorNoUrl()
        {
            var apikey = System.Environment.GetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY");

            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY", "apikey");
            var url = System.Environment.GetEnvironmentVariable("PERSONALITY_INSIGHTS_URL");

            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_URL", null);
            PersonalityInsightsService service = Substitute.For <PersonalityInsightsService>("versionDate");

            Assert.IsTrue(service.ServiceUrl.Contains("https://api.us-south.personality-insights.watson.cloud.ibm.com"));
            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_URL", url);
            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY", apikey);
        }
Esempio n. 23
0
        public void ConstructorNoUrl()
        {
            var apikey = System.Environment.GetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY");

            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY", "apikey");
            var url = System.Environment.GetEnvironmentVariable("PERSONALITY_INSIGHTS_URL");

            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_URL", null);
            PersonalityInsightsService service = Substitute.For <PersonalityInsightsService>("versionDate");

            Assert.IsTrue(service.ServiceUrl == "https://gateway.watsonplatform.net/personality-insights/api");
            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_URL", url);
            System.Environment.SetEnvironmentVariable("PERSONALITY_INSIGHTS_APIKEY", apikey);
        }
Esempio n. 24
0
        private IEnumerator CreateService()
        {
            IamAuthenticator authenticator = new IamAuthenticator(apikey: "{iamApikey}");

            //  Wait for tokendata
            while (!authenticator.CanAuthenticate())
            {
                yield return(null);
            }

            service = new PersonalityInsightsService("2019-02-18", authenticator);

            Runnable.Run(Examples());
        }
        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 GetProfileAsync_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.GetProfileAsync(options).ConfigureAwait(false);

            Assert.NotNull(profile);
        }
Esempio n. 27
0
        public ActionResult Sonuc([FromBody] WatsonPI.Gelen value)
        {
            try
            {
                if (value.Body != null && value.Body.Length > 0)

                {
                    var credential           = GoogleCredential.FromFile("C:\\Shelff-4e74dc12eb0d.json");
                    TranslationClient client = TranslationClient.Create(credential);
                    var response             = client.TranslateText(value.Body, "en");

                    string contentToProfile = response.TranslatedText;

                    PersonalityInsightsService _personalityInsights = new PersonalityInsightsService("6480d872-d50e-46bc-84e9-c24da9ea920b", "wWUDvxn3NdGw", "2017-10-13");

                    Content content = new Content()
                    {
                        ContentItems = new List <ContentItem>()
                        {
                            new ContentItem()
                            {
                                Contenttype = ContentItem.ContenttypeEnum.TEXT_PLAIN,
                                Language    = ContentItem.LanguageEnum.EN,
                                Content     = contentToProfile
                            }
                        }
                    };

                    var result = _personalityInsights.Profile(content, "text/plain", acceptLanguage: "application/json", rawScores: true, consumptionPreferences: true, csvHeaders: true);
                    WatsonPI.Sonuclar sonuc = new WatsonPI.Sonuclar {
                        Personality = result.Personality, Needs = result.Needs, Values = result.Values
                    };
                    return(Json(sonuc));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Esempio n. 28
0
        public Watson(Options opts)
        {
            var secrets = opts.Secrets();

            var keyNLU = secrets["IBMWatsonKeyNLU"];

            if (keyNLU == null)
            {
                throw new InvalidDataException("Missing NLU Key");
            }
            NLUService = new NaturalLanguageUnderstandingService("2020-08-01", new IamAuthenticator(apikey: $"{keyNLU}"));

            var keyPersonality = secrets["IBMWatsonKeyPersonality"];

            if (keyPersonality == null)
            {
                throw new InvalidDataException("Missing Personality Key");
            }
            PersonalityService = new PersonalityInsightsService("2020-08-01", new IamAuthenticator(apikey: $"{keyPersonality}"));
        }
        public void Setup()
        {
            #region Get Credentials
            if (string.IsNullOrEmpty(credentials))
            {
                var    parentDirectory     = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.FullName;
                string credentialsFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "credentials.json";
                if (File.Exists(credentialsFilepath))
                {
                    try
                    {
                        credentials = File.ReadAllText(credentialsFilepath);
                        credentials = Utility.AddTopLevelObjectToJson(credentials, "VCAP_SERVICES");
                    }
                    catch (Exception e)
                    {
                        throw new Exception(string.Format("Failed to load credentials: {0}", e.Message));
                    }
                }
                else
                {
                    Console.WriteLine("Credentials file does not exist.");
                }

                VcapCredentials vcapCredentials = JsonConvert.DeserializeObject <VcapCredentials>(credentials);
                var             vcapServices    = JObject.Parse(credentials);

                Credential credential = vcapCredentials.GetCredentialByname("personality-insights-sdk")[0].Credentials;
                endpoint = credential.Url;
                apikey   = credential.IamApikey;
            }
            #endregion

            TokenOptions tokenOptions = new TokenOptions()
            {
                IamApiKey  = apikey,
                ServiceUrl = endpoint
            };

            service = new PersonalityInsightsService(tokenOptions, "2016-10-20");
        }
        public void Profile_No_Accept()
        {
            PersonalityInsightsService service =
                new PersonalityInsightsService("username", "password", "versionDate");

            //  Test Profile
            ContentListContainer contentListContainer = new ContentListContainer()
            {
                ContentItems = new List <ContentItem>()
                {
                    new ContentItem()
                    {
                        Contenttype = ContentItem.ContenttypeEnum.TEXT_PLAIN,
                        Language    = ContentItem.LanguageEnum.EN,
                        Content     = content
                    }
                }
            };

            service.Profile("test", null, contentListContainer);
        }
        public void Profile()
        {
            IamAuthenticator authenticator = new IamAuthenticator(
                apikey: "{apikey}");

            PersonalityInsightsService service = new PersonalityInsightsService("2017-10-13", authenticator);

            service.SetServiceUrl("{serviceUrl}");

            Content content = null;

            content = JsonConvert.DeserializeObject <Content>(File.ReadAllText("profile.json"));

            var result = service.Profile(
                content: content,
                contentType: "application/json",
                rawScores: true,
                consumptionPreferences: true
                );

            Console.WriteLine(result.Response);
        }
Esempio n. 32
0
        public void Profile_No_Content_Type()
        {
            PersonalityInsightsService service =
                new PersonalityInsightsService("username", "password", "versionDate");


            //  Test Profile
            Content content = new Content()
            {
                ContentItems = new List <ContentItem>()
                {
                    new ContentItem()
                    {
                        Contenttype = ContentItem.ContenttypeEnum.TEXT_PLAIN,
                        Language    = ContentItem.LanguageEnum.EN,
                        Content     = contentString
                    }
                }
            };

            service.Profile(content, null);
        }
        public void Profile_Success()
        {
            _service = new PersonalityInsightsService(_username.ToString(), _password.ToString(), "2016-10-20");
            string contentToProfile = "The IBM Watson™ Personality Insights service provides a Representational State Transfer (REST) Application Programming Interface (API) that enables applications to derive insights from social media, enterprise data, or other digital communications. The service uses linguistic analytics to infer individuals' intrinsic personality characteristics, including Big Five, Needs, and Values, from digital communications such as email, text messages, tweets, and forum posts. The service can automatically infer, from potentially noisy social media, portraits of individuals that reflect their personality characteristics. The service can report consumption preferences based on the results of its analysis, and for JSON content that is timestamped, it can report temporal behavior.";

            Content content = new Content()
            {
                ContentItems = new List <ContentItem>()
                {
                    new ContentItem()
                    {
                        Contenttype = ContentItem.ContenttypeEnum.TEXT_PLAIN,
                        Language    = ContentItem.LanguageEnum.EN,
                        Content     = contentToProfile
                    }
                }
            };

            var result = _service.Profile(content, "text/plain", "application/json", rawScores: true, consumptionPreferences: true, csvHeaders: true);

            Assert.IsNotNull(result);
        }
Esempio n. 34
0
        public DetailedResponse <Profile> GetInsights(string text)
        {
            string apiKey      = _appConfiguration["WatsonAPIs:PersonalityInsights:Key"];
            string version     = _appConfiguration["WatsonAPIs:PersonalityInsights:Version"];
            string instanceURL = _appConfiguration["WatsonAPIs:PersonalityInsights:InstanceURL"];

            //Check settings are OK
            if (String.IsNullOrEmpty(apiKey) || String.IsNullOrEmpty(version) || String.IsNullOrEmpty(instanceURL))
            {
                throw new Exception("Invalid PersonalityInsights API configuration. Please check appsettings.json.");
            }

            IamAuthenticator           authenticator       = new IamAuthenticator(apikey: apiKey);
            PersonalityInsightsService personalityInsights = new PersonalityInsightsService(version, authenticator);

            personalityInsights.SetServiceUrl(instanceURL);
            personalityInsights.DisableSslVerification(true);

            Content            content = new Content();
            List <ContentItem> lst     = new List <ContentItem>();

            lst.Add(new ContentItem()
            {
                Content     = text,
                Contenttype = "text/plain",
                Language    = "en"
            });
            content.ContentItems = lst;

            return(personalityInsights.Profile(
                       content: content,
                       contentType: "text/plain",
                       rawScores: true,
                       consumptionPreferences: false
                       ));
        }
        public async Task GetProfileAsCsvAsync_IsNotNull()
        {
            var content = File.ReadAllText("SampleContent1.txt");

            var service = new PersonalityInsightsService(Settings.Username, Settings.Password);
            var options = new ProfileOptions(content)
            {
                IncludeRaw = true,
                IncludeCsvHeaders = true,
                AcceptLanguage = AcceptLanguage.Es
            };
            var profile = await service.GetProfileAsCsvAsync(options).ConfigureAwait(false);

            Assert.False(string.IsNullOrWhiteSpace(profile));
        }
        public async Task GetProfileAsJsonAsync_ValidOptions_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 options = new ProfileOptions("bob");

            var service = new PersonalityInsightsService("username", "password", httpCLient, new WatsonSettings());
            var profile = await service.GetProfileAsJsonAsync(options).ConfigureAwait(false);

            var mockResponseObj = JsonConvert.DeserializeObject(profile);
            var mockResponseJson = JsonConvert.SerializeObject(mockResponseObj);

            Assert.Equal(mockResponseJson, profile);
        }
Esempio n. 37
0
 public void Constructor_Version_Null()
 {
     PersonalityInsightsService service =
         new PersonalityInsightsService("username", "password", null);
 }
        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 void HttpClient_SetByConstructor2_IsValid()
        {
            var expectedUrl = "https://gateway.watsonplatform.net/personality-insights/api/";
            var service = new PersonalityInsightsService("username", "password", new WatsonSettings());

            Assert.NotNull(service);
            Assert.NotNull(service.HttpClient);
            Assert.NotNull(service.HttpClient.BaseAddress);

            Assert.Equal(expectedUrl, service.ServiceUrl);
            Assert.Equal(expectedUrl, service.HttpClient.BaseAddress.ToString());
        }