Esempio n. 1
0
        public void Setup()
        {
            DBName = TestConstants.defaultDatabaseName + DateTime.Now.Ticks;

            client = new CloudantClientBuilder(TestConstants.account)
            {
                username = TestConstants.username,
                password = TestConstants.password
            }.GetResult();

            // create the database
            try
            {
                db = client.Database(DBName);
                db.EnsureExistsAsync().Wait();
                Assert.NotNull(db);
            }
            catch (AggregateException ae)
            {
                Assert.Fail("Create remote database failed.  Cause: " + ae.Message);
            }
            catch (Exception e)
            {
                Assert.Fail("Unexpected failure: " + e.Message);
            }
        }
 public void FixtureSetup()
 {
     client = new CloudantClientBuilder(TestConstants.account)
     {
         username = TestConstants.username,
         password = TestConstants.password
     }.GetResult();
 }
Esempio n. 3
0
 public CloudantClient_Operations()
 {
     _cloudantClient = new CloudantClient(new CloudantConnection(
                                              Environment.GetEnvironmentVariable("CLOUDANT_URL"),
                                              Environment.GetEnvironmentVariable("CLOUDANT_USER"),
                                              Environment.GetEnvironmentVariable("CLOUDANT_TOKEN")
                                              ));
 }
        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.");
        }
Esempio n. 5
0
        public void setup()
        {
            client = new CloudantClientBuilder(TestConstants.account)
            {
                username = TestConstants.username,
                password = TestConstants.password
            }.GetResult();

            string DBName = "httphelpertests" + DateTime.Now.Ticks;

            db = client.Database(DBName);
            db.EnsureExistsAsync().Wait();
        }
        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.");
        }
Esempio n. 7
0
        public void testCookieInterceptor()
        {
            CookieInterceptor cookieInterceptor = new CookieInterceptor(TestConstants.username, TestConstants.password);

            client = new CloudantClientBuilder(TestConstants.account)
            {
                interceptors = new List <IHttpConnectionInterceptor>()
                {
                    cookieInterceptor
                }
            }.GetResult();

            db = client.Database(DBName);

            Assert.DoesNotThrow(async() =>
            {
                await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
            },
                                "Exception thrown while creating database using cookie interceptor. ");

            Assert.NotNull(db);
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CrossPlatformSample.HomePage"/> class.
        /// </summary>
        /// <param name="client">Valid CloudantClient object initialized with the account information.</param>
        public HomePage(CloudantClient client)
        {
            this.client = client;

            //List of sample items.
            List <CommandItem> items = new List <CommandItem>
            {
                new CommandItem {
                    Title = " 1. Create Database", ItemSelected = OnCreateDB
                },
                new CommandItem {
                    Title = " 2. Save Document", ItemSelected = OnSaveDocument
                },
                new CommandItem {
                    Title = " 3. Retrieve Document", ItemSelected = OnRetrieveDocument
                },
                new CommandItem {
                    Title = " 4. Update Document", ItemSelected = OnUpdateDocument
                },
                new CommandItem {
                    Title = " 5. Create Index", ItemSelected = OnCreateIndex
                },
                new CommandItem {
                    Title = " 6. List Indexes", ItemSelected = OnListIndexes
                },
                new CommandItem {
                    Title = " 7. Query Index", ItemSelected = OnQuery
                },
                new CommandItem {
                    Title = " 8. Delete Index", ItemSelected = OnDeleteIndex
                },
                new CommandItem {
                    Title = " 9. Delete Database", ItemSelected = OnDeleteDB
                }
            };

            InitializeUserInterface(items);
        }