本文整理匯總了C#中MongoDB.Driver.CommandResult.Initialize方法的典型用法代碼示例。如果您正苦於以下問題:C# CommandResult.Initialize方法的具體用法?C# CommandResult.Initialize怎麽用?C# CommandResult.Initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MongoDB.Driver.CommandResult
的用法示例。
在下文中一共展示了CommandResult.Initialize方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestErrorMessagePresent
public void TestErrorMessagePresent()
{
var document = new BsonDocument("errmsg", "An error message");
var result = new CommandResult();
result.Initialize(document);
Assert.AreEqual("An error message", result.ErrorMessage);
}
示例2: TestErrorMessageNotString
public void TestErrorMessageNotString()
{
var document = new BsonDocument("errmsg", 3.14159);
var result = new CommandResult();
result.Initialize(document);
Assert.AreEqual("3.14159", result.ErrorMessage);
}
示例3: TestErrorMessageMissing
public void TestErrorMessageMissing()
{
var document = new BsonDocument();
var result = new CommandResult();
result.Initialize(document);
Assert.AreEqual("Unknown error", result.ErrorMessage);
}
示例4: TestOkFalse
public void TestOkFalse()
{
var document = new BsonDocument("ok", false);
var result = new CommandResult();
result.Initialize(document);
Assert.IsFalse(result.Ok);
Assert.IsNotNull(result.ErrorMessage);
}
示例5: TestOkOnePointZero
public void TestOkOnePointZero()
{
var document = new BsonDocument("ok", 1.0);
var result = new CommandResult();
result.Initialize(document);
Assert.IsTrue(result.Ok);
Assert.IsNull(result.ErrorMessage);
}
示例6: TestOkMissing
public void TestOkMissing()
{
var document = new BsonDocument();
var result = new CommandResult();
result.Initialize(document);
Assert.Throws<MongoCommandException>(() => { var dummy = result.Ok; });
}