當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。