Esempio n. 1
0
 public void testEnsureExistsDoesntErrorWhenCalledTwice()
 {
     db = client.Database(DBName);
     Assert.DoesNotThrow(async() =>
     {
         await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
         await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
     });
 }
Esempio n. 2
0
        public void testCreateDocumentInDbWithSlash()
        {
            var db = client.Database("my/database");

            try
            {
                db.EnsureExistsAsync().Wait();

                var document = new DocumentRevision()
                {
                    docId = "my/document",
                    body  = new Dictionary <string, Object>()
                    {
                        ["hello"] = "world"
                    }
                };

                var savedDocument = CreateAndAssert(document);

                //read
                ReadAndAssert(document, savedDocument);

                // update
                var updated = UpdateAndAssert(document, savedDocument);

                // delete
                DeleteAndAssert(updated);
            }
            finally
            {
                db.DeleteAsync().Wait();
            }
        }
Esempio n. 3
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 NonExistentDatabaseException()
        {
            string DBName = "database_doesnt_exist";
            var    db     = client.Database(DBName);

            Assert.Throws <DataException>(async() => await db.ListIndicesAsync(),
                                          "Test failed checking that exception is thrown when a database doesn't exist.");
        }
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();
        }
Esempio n. 6
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);
        }