本文整理汇总了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);
}
}
示例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);
}
示例3: testEnsureExistsDoesntErrorWhenCalledTwice
public void testEnsureExistsDoesntErrorWhenCalledTwice()
{
db = client.Database(DBName);
Assert.DoesNotThrow(async () =>
{
await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
await db.EnsureExistsAsync().ConfigureAwait(continueOnCapturedContext: false);
});
}
示例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);
}
示例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");
}
}
示例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();
}