WriteDouble() public method

Writes a BSON Double to the writer.
public WriteDouble ( double value ) : void
value double The Double value.
return void
Exemplo n.º 1
0
 public void TestTwoDoubles()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteDouble("a", 1.5);
         writer.WriteDouble("b", 2.5);
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'a' : 1.5, 'b' : 2.5 }".Replace("'", "\""); ;
     Assert.Equal(expected, json);
 }
Exemplo n.º 2
0
 public void TestOneNestedDouble()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteStartDocument("nested");
         writer.WriteDouble("a", 1.5);
         writer.WriteEndDocument();
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'nested' : { 'a' : 1.5 } }".Replace("'", "\"");
     Assert.Equal(expected, json);
 }