当前位置: 首页>>代码示例>>C#>>正文


C# Database.EnsureExistsAsync方法代码示例

本文整理汇总了C#中Database.EnsureExistsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Database.EnsureExistsAsync方法的具体用法?C# Database.EnsureExistsAsync怎么用?C# Database.EnsureExistsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database.EnsureExistsAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

        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);
            }
        }
开发者ID:cloudant,项目名称:xamarin-cloudant,代码行数:26,代码来源:DatabaseCRUDTests.cs

示例2: testBasicAuthInterceptor

        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);
        }
开发者ID:cloudant,项目名称:xamarin-cloudant,代码行数:19,代码来源:InterceptorsTests.cs

示例3: testEnsureExistsDoesntErrorWhenCalledTwice

 public void testEnsureExistsDoesntErrorWhenCalledTwice()
 {
     db = client.Database(DBName);
     Assert.DoesNotThrow(async () =>
         {
             await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
             await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
         });
 }
开发者ID:cloudant,项目名称:xamarin-cloudant,代码行数:9,代码来源:CloudantClientDatabaseTests.cs

示例4: testDBCreationGreenPath

        public void testDBCreationGreenPath()
        {
            db = client.Database(DBName);
            db.EnsureExistsAsync().Wait();
            Assert.NotNull(db);

            //Test db names are url encoded
            string databaseName = "az09_$()+-/";
            Assert.DoesNotThrow(async () =>
                {
                    var newDb = client.Database(databaseName);
                    await newDb.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
                    //Clean up
                    await newDb.DeleteAsync().ConfigureAwait(continueOnCapturedContext: false);
                },
                "Test failed to create a database with name " + databaseName);
        }
开发者ID:cloudant,项目名称:xamarin-cloudant,代码行数:17,代码来源:CloudantClientDatabaseTests.cs

示例5: OnCreateDB

        /// <summary>
        /// Code sample to create a database.
        /// </summary>
        private void OnCreateDB()
        {
            try
            {
                db = client.Database(dbName);
                db.EnsureExistsAsync();
                DisplayAlert("Database Created", "Database name: " + db.dbname, "OK");

            }
            catch (Exception e)
            {
                HandleException(e, "Create Database Failed");
            }
        }
开发者ID:cloudant,项目名称:xamarin-cloudant,代码行数:17,代码来源:HomePage.cs

示例6: setup

        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();
        }
开发者ID:cloudant,项目名称:xamarin-cloudant,代码行数:12,代码来源:IndexTests.cs


注:本文中的Database.EnsureExistsAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。