本文整理汇总了C#中BsonDocument.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.Equals方法的具体用法?C# BsonDocument.Equals怎么用?C# BsonDocument.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonDocument
的用法示例。
在下文中一共展示了BsonDocument.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: T00_TestIncrement
public void T00_TestIncrement()
{
// basic $inc
{
var doc1 = new BsonDocument { { "count", 4 } };
var update_cmds = new BsonDocument { { "$inc", new BsonDocument { { "count", 5 } } } };
var doc2 = new BsonDocument { { "count", 9 } };
Assert.True(!doc2.Equals(doc1), "(basic inc) shouldn't be equal before apply");
BsonHelper.applyUpdateCommands(doc1, update_cmds);
Assert.True(doc2.Equals(doc1), "(basic inc) inc didn't apply");
}
// $inc a.b.c + 2
{
var doc1 = new BsonDocument {
{ "a", new BsonDocument {
{ "count" , 4 }
}
}};
var update_cmds = new BsonDocument { { "$inc", new BsonDocument { { "a.count", 5 } } } };
var doc2 = new BsonDocument {
{ "a", new BsonDocument {
{ "count" , 9 }
}
}};
Assert.True(!doc2.Equals(doc1), "(nested key inc) shouldn't be equal before apply");
BsonHelper.applyUpdateCommands(doc1, update_cmds);
Assert.True(doc2.Equals(doc1), "(nested key inc) inc didn't apply");
}
}
示例2: TestSingleString
public void TestSingleString() {
BsonDocument document = new BsonDocument() { { "abc", "xyz" } };
using (var bsonReader = BsonReader.Create(document)) {
var rehydrated = BsonDocument.ReadFrom(bsonReader);
Assert.IsTrue(document.Equals(rehydrated));
}
}
示例3: TestEmptyDocument
public void TestEmptyDocument() {
BsonDocument document = new BsonDocument();
using (var bsonReader = BsonReader.Create(document)) {
var rehydrated = BsonDocument.ReadFrom(bsonReader);
Assert.IsTrue(document.Equals(rehydrated));
}
}
示例4: AutoVivifyCanExtendLeafByOneArrArr
public void AutoVivifyCanExtendLeafByOneArrArr()
{
var bson = new BsonDocument("test", new BsonDocument("arr", new BsonArray()));
bson.AvArray("test.arr[0]").Add("baz");
var expected = "{'test':{'arr':[['baz']]}}}".ParseBsonDocument();
Assert.That(bson.Equals(expected));
}
示例5: AutoVivifyCanAddressLeafPathsDocArr
public void AutoVivifyCanAddressLeafPathsDocArr()
{
var bson = new BsonDocument("test", new BsonDocument("doc", new BsonDocument()));
bson.AvArray("test.doc.bar").Add("baz");
var expected = "{'test':{'doc':{'bar':['baz']}}}".ParseBsonDocument();
Assert.That(bson.Equals(expected));
}
示例6: AutoVivifyCanAddressLeafPathsDoc
public void AutoVivifyCanAddressLeafPathsDoc()
{
var bson = new BsonDocument("test", new BsonDocument("doc", new BsonDocument()));
bson.AvDocument("test.doc")["bar"] = "baz";
var expected = "{'test':{'doc':{'bar':'baz'}}}".ParseBsonDocument();
Assert.That(bson.Equals(expected));
}
示例7: TestArray
public void TestArray()
{
BsonDocument document = new BsonDocument() {
{ "array", new BsonArray { 1, 2, 3 } }
};
var rehydrated = BsonDocument.ReadFrom(BsonReader.Create(document));
Assert.IsTrue(document.Equals(rehydrated));
}
示例8: TestBinary
public void TestBinary()
{
var document = new BsonDocument {
{ "bin", new BsonBinaryData(new byte[] { 1, 2, 3 }) }
};
var rehydrated = BsonDocument.ReadFrom(BsonReader.Create(document));
Assert.IsTrue(document.Equals(rehydrated));
}
示例9: TestEmbeddedDocument
public void TestEmbeddedDocument()
{
BsonDocument document = new BsonDocument() {
{ "doc", new BsonDocument { { "a", 1 }, { "b", 2 } } }
};
var rehydrated = BsonDocument.ReadFrom(BsonReader.Create(document));
Assert.IsTrue(document.Equals(rehydrated));
}
示例10: TestSingleString
public void TestSingleString()
{
BsonDocument document = new BsonDocument() { { "abc", "xyz" } };
using (var bsonReader = new BsonDocumentReader(document))
{
var rehydrated = DeserializeBsonDocument(bsonReader);
Assert.True(document.Equals(rehydrated));
}
}
示例11: TestEmptyDocument
public void TestEmptyDocument()
{
BsonDocument document = new BsonDocument();
using (var bsonReader = new BsonDocumentReader(document))
{
var rehydrated = DeserializeBsonDocument(bsonReader);
Assert.True(document.Equals(rehydrated));
}
}
示例12: TestSingleString
public void TestSingleString()
{
BsonDocument document = new BsonDocument() { { "abc", "xyz" } };
using (var bsonReader = BsonReader.Create(document))
{
var rehydrated = (BsonDocument)BsonDocumentSerializer.Instance.Deserialize(bsonReader, typeof(BsonDocument), null);
Assert.IsTrue(document.Equals(rehydrated));
}
}
示例13: TestDateTime
public void TestDateTime()
{
DateTime jan_1_2010 = new DateTime(2010, 1, 1);
BsonDocument document = new BsonDocument() {
{ "date", jan_1_2010 }
};
var rehydrated = BsonDocument.ReadFrom(BsonReader.Create(document));
Assert.IsTrue(document.Equals(rehydrated));
}
示例14: TestDateTime
public void TestDateTime() {
DateTime jan_1_2010 = DateTime.SpecifyKind(new DateTime(2010, 1, 1), DateTimeKind.Utc);
BsonDocument document = new BsonDocument() {
{ "date", jan_1_2010 }
};
using (var bsonReader = BsonReader.Create(document)) {
var rehydrated = BsonDocument.ReadFrom(bsonReader);
Assert.IsTrue(document.Equals(rehydrated));
}
}
示例15: TestArray
public void TestArray()
{
BsonDocument document = new BsonDocument
{
{ "array", new BsonArray { 1, 2, 3 } }
};
using (var bsonReader = new BsonDocumentReader(document))
{
var rehydrated = DeserializeBsonDocument(bsonReader);
Assert.True(document.Equals(rehydrated));
}
}