本文整理汇总了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; });
}