ToString() public method

public ToString ( ) : string
return string
        public void TestBuilderSetsAllProperties()
        {
            Document query = new Document().Append("x",1);
            Document scope = new Document().Append("y",2);
            Document sort = new Document().Append("z",3);
            MapReduceBuilder mrb = mrcol.MapReduceBuilder();
            mrb.Map(mapfunction)
                    .Reduce(reducefunction)
                    .KeepTemp(true)
                    .Limit(5)
                    .Out("outtest")
                    .Query(query)
                    .Scope(scope)
                    .Sort(sort)
                    .Verbose(false);

            MapReduce mr = mrb.MapReduce;
            Assert.AreEqual(query.ToString(), mr.Query.ToString());
            Assert.AreEqual(scope.ToString(), mr.Scope.ToString());
            Assert.AreEqual(sort.ToString(), mr.Sort.ToString());
            Assert.AreEqual(true, mr.KeepTemp);
            Assert.AreEqual(5, mr.Limit);
            Assert.AreEqual("outtest", mr.Out);
            Assert.AreEqual(false, mr.Verbose);
        }
示例#2
0
        public void TestRoundTrip()
        {
            Document idoc = new Document();
            idoc.Add("b",new Binary(new byte[]{(byte)1,(byte)2}));

            MemoryStream stream = new MemoryStream();
            BsonWriter writer = new BsonWriter(stream);
            writer.Write(idoc);

            stream.Seek(0,SeekOrigin.Begin);
            BsonReader reader = new BsonReader(stream);
            Document odoc = reader.Read();

            Assert.AreEqual(idoc.ToString(), odoc.ToString());
        }
示例#3
0
        public void TestRoundTrip()
        {
            Document idoc = new Document();
            idoc.Add("b",new Binary(new byte[]{(byte)1,(byte)2}));
            BsonDocument bidoc = BsonConvert.From(idoc);

            MemoryStream stream = new MemoryStream();
            BsonWriter writer = new BsonWriter(stream);
            bidoc.Write(writer);

            stream.Seek(0,SeekOrigin.Begin);
            BsonReader reader = new BsonReader(stream);
            BsonDocument bodoc = new BsonDocument();
            bodoc.Read(reader);
            Document odoc = (Document) bodoc.ToNative();

            Assert.AreEqual(idoc.ToString(), odoc.ToString());
        }
示例#4
0
        public void TestInsertOfArray()
        {
            OidGenerator ogen = new OidGenerator();
            IMongoCollection inserts = DB["inserts"];
            Document album = new Document();
            album["_id"] = ogen.Generate();
            album["artist"] = "Popa Chubby";
            album["title"] = "Deliveries After Dark";
            album["songs"] = new[] {
                new Document().Append("title", "Let The Music Set You Free").Append("length", "5:15").Append("_id", ogen.Generate()),
                new Document().Append("title", "Sally Likes to Run").Append("length", "4:06").Append("_id", ogen.Generate()),
                new Document().Append("title", "Deliveries After Dark").Append("length", "4:17").Append("_id", ogen.Generate()),
                new Document().Append("title", "Theme From The Godfather").Append("length", "3:06").Append("_id", ogen.Generate()),
                new Document().Append("title", "Grown Man Crying Blues").Append("length", "8:09").Append("_id", ogen.Generate()),
            };
            inserts.Insert(album);

            Document result = inserts.FindOne(new Document().Append("songs.title","Deliveries After Dark"));
            Assert.IsNotNull(result);

            Assert.AreEqual(album.ToString(), result.ToString());
        }
 public void TestToStringForDocWithArrayOfDocs()
 {
     var doc = new Document().Append("foo", new[] {
         new Document().Append("a", 1),
         new Document().Append("b", 2),
         new Document().Append("c", 3),
     });
     Assert.AreEqual(@"{ ""foo"": [ { ""a"": 1 }, { ""b"": 2 }, { ""c"": 3 } ] }", doc.ToString());
 }
 public void TestToStringForDocWithSubDocField()
 {
     var doc = new Document().Append("foo", "bar").Append("baz", new Document().Append("a", 1));
     Assert.AreEqual(@"{ ""foo"": ""bar"", ""baz"": { ""a"": 1 } }", doc.ToString());
 }
 public void TestToStringForDocWithSingleTrueField()
 {
     var doc = new Document().Append("foo", true);
     Assert.AreEqual(@"{ ""foo"": true }", doc.ToString());
 }
 public void TestToStringForDocWithSingleStringField()
 {
     var doc = new Document().Append("foo", "bar");
     Assert.AreEqual(@"{ ""foo"": ""bar"" }", doc.ToString());
 }
 public void TestToStringForDocWithSingleOidField()
 {
     var doc = new Document().Append("foo", new Oid("4ac7ee91f693066f1c96b649"));
     Assert.AreEqual(@"{ ""foo"": ObjectId(""4ac7ee91f693066f1c96b649"") }", doc.ToString());
 }
示例#10
0
 public void TestToStringForDocWithSingleNullField()
 {
     var doc = new Document().Append("foo", null);
     Assert.AreEqual(@"{ ""foo"": null }", doc.ToString());
 }
示例#11
0
 public void TestToStringForDocWithSingleIntField()
 {
     var doc = new Document().Append("foo", 10);
     Assert.AreEqual(@"{ ""foo"": 10 }", doc.ToString());
 }
示例#12
0
 public void TestToStringForDocWithSingleDateTimeField()
 {
     var doc = new Document().Append("foo", DateTime.Parse("2009-10-10T07:00:00.0000000Z"));
     Assert.AreEqual(@"{ ""foo"": ""2009-10-10T07:00:00.0000000Z"" }", doc.ToString());
 }
示例#13
0
 public void TestToStringForDocWithMultipleFields()
 {
     var doc = new Document().Append("foo", "bar").Append("baz", 42);
     Assert.AreEqual(@"{ ""foo"": ""bar"", ""baz"": 42 }", doc.ToString());
 }
示例#14
0
 public void TestToStringForDocWithArrayOfInts()
 {
     var doc = new Document().Append("foo", new[] {1,2,3,4});
     Assert.AreEqual(@"{ ""foo"": [ 1, 2, 3, 4 ] }", doc.ToString());
 }
示例#15
0
 public override string ToString()
 {
     return(result.ToString());
 }
示例#16
0
 public override string ToString()
 {
     return(doc.ToString());
 }