Cloudant client builder.
This class is used for building a CloudantClient with specified options.
 public void BuilderStripsUserNameAndPassword()
 {
     var builder = new CloudantClientBuilder(new Uri("https://*****:*****@username.cloudant.com"));
     Assert.AreEqual("username", builder.username);
     Assert.AreEqual("password", builder.password);
     Assert.AreEqual(new Uri("https://username.cloudant.com"), builder.accountUri);
 }
        /// <summary>
        /// Constructs a new instance of this class and connects to the cloudant server using a builder class.
        /// </summary>
        /// <param name="builder">Builder class. <see cref="IBM.Cloudant.Client.CloudantClientBuilder"/> </param>
        public CloudantClient(CloudantClientBuilder builder)
        {
            this.accountUri = builder.accountUri;
            this.username = builder.username;
            this.password = builder.password;

            List<IHttpConnectionInterceptor> interceptors = new List<IHttpConnectionInterceptor>();
            if (builder.interceptors != null)
            {
                interceptors.AddRange(builder.interceptors);
            }

            if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
            {
                var cookieInterceptor = new CookieInterceptor(username, password);
                interceptors.Add(cookieInterceptor);
            }

            InitHttpHelper(interceptors);
        }
        /// <summary>
        /// Constructs a new instance of this class and connects to the cloudant server using a builder class.
        /// </summary>
        /// <param name="builder">Builder class. <see cref="IBM.Cloudant.Client.CloudantClientBuilder"/> </param>
        public CloudantClient(CloudantClientBuilder builder)
        {
            this.accountUri = builder.accountUri;
            this.username   = builder.username;
            this.password   = builder.password;


            List <IHttpConnectionInterceptor> interceptors = new List <IHttpConnectionInterceptor>();

            if (builder.interceptors != null)
            {
                interceptors.AddRange(builder.interceptors);
            }

            if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
            {
                var cookieInterceptor = new CookieInterceptor(username, password);
                interceptors.Add(cookieInterceptor);
            }

            InitHttpHelper(interceptors);
        }
        public App()
        {
            //Validate configuration on AppSettings.cs has been changed
            if (AppSettings.account.StartsWith("your-cloudant") || AppSettings.username.StartsWith("your-cloudant") || AppSettings.password.StartsWith("your-cloudant"))
                MainPage = new ConfigErrorPage("To run this sample, you must first modify AppSettings.cs to provide your Cloudant account.");
            else
            {
                try
                {
                    CloudantClient client = new CloudantClientBuilder(AppSettings.account)
                    {
                        username = AppSettings.username,
                        password = AppSettings.password
                    }.GetResult();

                    MainPage = new HomePage(client);

                }
                catch (Exception e)
                {
                    MainPage = new ConfigErrorPage("Unable to create a CloudantClient. One or more account parameter in AppSettings.cs is incorrect. " + e.Message);
                }
            }
        }
 public void BuilderPassesThroughURIWithNoCreds()
 {
     var builder = new CloudantClientBuilder(new Uri("https://username.cloudant.com"));
     Assert.AreEqual(new Uri("https://username.cloudant.com"), builder.accountUri);
 }
 public void TestGreenPath()
 {
     //Test CloudantClient creation with valid parms.
     CloudantClient testClient = null;
     Assert.DoesNotThrow(() =>
         testClient = new CloudantClientBuilder(TestConstants.account)
         {
             username = TestConstants.username,
             password = TestConstants.password
         }.GetResult(),
         "Test failed while instantiationg a CloudantClient using valid parameters.");
     Assert.IsNotNull(testClient, "Test failed because client object must not be null after it has been built with valid parms.");
 }
 public void TestClientCreationValidAccount()
 {
     //Test CloudantClient creation with valid accountUri
     CloudantClient testClient = null;
     Uri validUri = new Uri(string.Format("https://{0}", TestConstants.account));
     Assert.DoesNotThrow(() =>
         testClient = new CloudantClientBuilder(validUri).GetResult(),
         "Test failed while instantiationg a CloudantClient using a valid uri.");
     Assert.IsNotNull(testClient, "Test failed because client object must not be null after it has been built with a valid uri.");
 }