WriteNull() публичный Метод

Writes a BSON null to the writer.
public WriteNull ( ) : void
Результат void
Пример #1
0
 public void TestOneNull()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteNull("a");
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'a' : null }".Replace("'", "\""); ;
     Assert.Equal(expected, json);
 }
Пример #2
0
 public void TestTwoNestedNulls()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteStartDocument("nested");
         writer.WriteNull("a");
         writer.WriteNull("b");
         writer.WriteEndDocument();
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'nested' : { 'a' : null, 'b' : null } }".Replace("'", "\"");
     Assert.Equal(expected, json);
 }