WriteUndefined() 공개 메소드

Writes a BSON undefined to the writer.
public WriteUndefined ( ) : void
리턴 void
예제 #1
0
 public void TestOneUndefined()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteUndefined("a");
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'a' : undefined }".Replace("'", "\""); ;
     Assert.Equal(expected, json);
 }
 public void TestTwoNestedUndefineds()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteStartDocument("nested");
         writer.WriteUndefined("a");
         writer.WriteUndefined("b");
         writer.WriteEndDocument();
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'nested' : { 'a' : undefined, 'b' : undefined } }".Replace("'", "\"");
     Assert.AreEqual(expected, json);
 }