Database() public method

Creates a database object that represents a database on the server. However the database may not exist on the server yet. You should call IBM.Cloudant.Client.Database.EnsureExistsAsync to ensure the database exists on the server before performing reads or writes.
public Database ( String dbname ) : Database
dbname String name of database to access
return Database
        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 testBasicAuthInterceptor()
        {
            BasicAuthenticationInterceptor basicAuthInterceptor = new BasicAuthenticationInterceptor(TestConstants.username, TestConstants.password);

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

            db = client.Database(DBName);

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

            Assert.NotNull(db);
        }
示例#3
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();
        }