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


C# BsonDocument.Equals方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:35,代码来源:BsonHelperTests.cs

示例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));
     }
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonDocumentReaderTests.cs

示例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));
     }
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonDocumentReaderTests.cs

示例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));
 }
开发者ID:tanglebones,项目名称:ch-bson,代码行数:7,代码来源:AutoVivify.cs

示例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));
 }
开发者ID:tanglebones,项目名称:ch-bson,代码行数:7,代码来源:AutoVivify.cs

示例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));
 }
开发者ID:tanglebones,项目名称:ch-bson,代码行数:7,代码来源:AutoVivify.cs

示例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));
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BsonDocumentReaderTests.cs

示例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));
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BsonDocumentReaderTests.cs

示例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));
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BsonDocumentReaderTests.cs

示例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));
     }
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:9,代码来源:BsonDocumentReaderTests.cs

示例11: TestEmptyDocument

 public void TestEmptyDocument()
 {
     BsonDocument document = new BsonDocument();
     using (var bsonReader = new BsonDocumentReader(document))
     {
         var rehydrated = DeserializeBsonDocument(bsonReader);
         Assert.True(document.Equals(rehydrated));
     }
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:9,代码来源:BsonDocumentReaderTests.cs

示例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));
     }
 }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonDocumentReaderTests.cs

示例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));
 }
开发者ID:modesto,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonDocumentReaderTests.cs

示例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));
     }
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonDocumentReaderTests.cs

示例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));
     }
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:12,代码来源:BsonDocumentReaderTests.cs


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