public void SupportsBoolTrue() {
            var mapper = new AttributesMappingManager();
            var ser = new SolrDocumentSerializer<TestDocWithBool>(mapper, new DefaultFieldSerializer());
			var doc = new TestDocWithBool {B = true};
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
			Assert.AreEqual("<doc><field name=\"B\">true</field></doc>", fs);
		}
		public void AcceptsSparseCollections() {
            var mapper = new AttributesMappingManager();
            var ser = new SolrDocumentSerializer<TestDocWithCollections>(mapper, new DefaultFieldSerializer());
			var doc = new TestDocWithCollections { coll = new[] { "one", null, "two" } };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
			Assert.AreEqual("<doc><field name=\"coll\">one</field><field name=\"coll\">two</field></doc>", fs);
		}
		public void AcceptsEmptyCollections() {
            var mapper = new AttributesMappingManager();
            var ser = new SolrDocumentSerializer<TestDocWithCollections>(mapper, new DefaultFieldSerializer());
			var doc = new TestDocWithCollections { coll = new string[] { null, null } };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
			Assert.AreEqual("<doc />", fs);
		}
 public void AcceptsNullObjects()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
     var doc = new SampleDoc {Id = null};
     ser.Serialize(doc, null).ToString();
 }
		public void EscapesStrings() {
            var mapper = new AttributesMappingManager();
            var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
			var doc = new SampleDoc {Id = "<quote\""};
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
            Assert.AreEqual("<doc><field name=\"Id\">&lt;quote\"</field><field name=\"Flower\">0</field></doc>", fs);
		}
		public void SupportsDateTime() {
            var mapper = new AttributesMappingManager();
            var ser = new SolrDocumentSerializer<TestDocWithDate>(mapper, new DefaultFieldSerializer());
			var doc = new TestDocWithDate {Date = new DateTime(2001, 1, 2, 3, 4, 5)};
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
			Assert.AreEqual("<doc><field name=\"Date\">2001-01-02T03:04:05Z</field></doc>", fs);
		}
Esempio n. 7
0
        public void SupportsCollections()
        {
            var    mapper = new AttributesMappingManager();
            var    ser    = new SolrDocumentSerializer <TestDocWithCollections>(mapper, new DefaultFieldSerializer());
            var    doc    = new TestDocWithCollections();
            string fs     = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"coll\">one</field><field name=\"coll\">two</field></doc>", fs);
        }
Esempio n. 8
0
        public void SupportsNullableDateTime()
        {
            var    mapper = new AttributesMappingManager();
            var    ser    = new SolrDocumentSerializer <TestDocWithNullableDate>(mapper, new DefaultFieldSerializer());
            var    doc    = new TestDocWithNullableDate();
            string fs     = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc />", fs);
        }
Esempio n. 9
0
        public void AcceptsNullObjects()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <SampleDoc>(mapper, new DefaultFieldSerializer());
            var doc    = new SampleDoc {
                Id = null
            };

            ser.Serialize(doc, null).ToString();
        }
 public void FieldBoost()
 {
     var mapper = new AttributesMappingManager();
     ISolrDocumentSerializer<TestDocWithBoostedString> ser = new SolrDocumentSerializer<TestDocWithBoostedString>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithBoostedString {
         Desc = "hello"
     };
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual(@"<doc><field name=""Desc"" boost=""1.45"">hello</field></doc>", fs);
 }
 public void Serializes()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
     var doc = new SampleDoc {Id = "id", Dd = 23.5m};
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Assert.AreEqual("<doc><field name=\"Id\">id</field><field name=\"Flower\">23.5</field></doc>", fs);
 }
 public void AcceptsNullObjects()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
     var doc = new SampleDoc {Id = null};
     string fs = ser.Serialize(doc, null).OuterXml;
     Console.WriteLine(fs);
     var xml = new XmlDocument();
     xml.LoadXml(fs);
 }
Esempio n. 13
0
        public void PropertyWithoutGetter()
        {
            var    mapper = new AttributesMappingManager();
            var    ser    = new SolrDocumentSerializer <TestDocWithoutGetter>(mapper, new DefaultFieldSerializer());
            string fs     = ser.Serialize(new TestDocWithoutGetter(), null).OuterXml;
            var    xml    = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
        }
Esempio n. 14
0
        public void SupportsGuid()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithGuid>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithGuid {
                Key = Guid.NewGuid()
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"Key\">" + doc.Key + "</field></doc>", fs);
        }
Esempio n. 15
0
        public void SupportsCollections()
        {
            var    mapper = new AttributesMappingManager();
            var    ser    = new SolrDocumentSerializer <TestDocWithCollections>(mapper, new DefaultFieldSerializer());
            var    doc    = new TestDocWithCollections();
            string fs     = ser.Serialize(doc, null).OuterXml;
            var    xml    = new XmlDocument();

            xml.LoadXml(fs);
            Assert.AreEqual("<doc><field name=\"coll\">one</field><field name=\"coll\">two</field></doc>", fs);
        }
Esempio n. 16
0
        public void Serializes()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <SampleDoc>(mapper, new DefaultFieldSerializer());
            var doc    = new SampleDoc {
                Id = "id", Dd = 23.5m
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"Id\">id</field><field name=\"Flower\">23.5</field></doc>", fs);
        }
        public void AcceptsSparseCollections()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithCollections>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithCollections {
                coll = new[] { "one", null, "two" }
            };
            var fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.AreEqual("<doc><field name=\"coll\">one</field><field name=\"coll\">two</field></doc>", fs);
        }
Esempio n. 18
0
        public void SupportsBoolFalse()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithBool>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithBool {
                B = false
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"B\">false</field></doc>", fs);
        }
Esempio n. 19
0
        public void EscapesStrings()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <SampleDoc>(mapper, new DefaultFieldSerializer());
            var doc    = new SampleDoc {
                Id = "<quote\""
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"Id\">&lt;quote\"</field><field name=\"Flower\">0</field></doc>", fs);
        }
Esempio n. 20
0
        public void Location()
        {
            var mapper  = new AttributesMappingManager();
            var ser     = new SolrDocumentSerializer <TestDocWithLocation>(mapper, new DefaultFieldSerializer());
            var testDoc = new TestDocWithLocation {
                Loc = new Location(12.2, -12.3)
            };
            string fs = ser.Serialize(testDoc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal(@"<doc><field name=""location"">12.2,-12.3</field></doc>", fs);
        }
 public void EscapesStrings()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
     var doc = new SampleDoc {Id = "<quote\""};
     string fs = ser.Serialize(doc, null).OuterXml;
     Console.WriteLine(fs);
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Assert.AreEqual("<doc><field name=\"Id\">&lt;quote\"</field><field name=\"Flower\">0</field></doc>", fs);
 }
Esempio n. 22
0
        public void SupportsDateTime()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithDate>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithDate {
                Date = new DateTime(2001, 1, 2, 3, 4, 5)
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"Date\">2001-01-02T03:04:05Z</field></doc>", fs);
        }
Esempio n. 23
0
        public void UTF_XML()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithString>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithString {
                Desc = @"ÚóÁ⌠╒"""
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal(@"<doc><field name=""Desc"">ÚóÁ⌠╒""</field></doc>", fs);
        }
Esempio n. 24
0
        public void FieldBoost()
        {
            var mapper = new AttributesMappingManager();
            ISolrDocumentSerializer <TestDocWithBoostedString> ser = new SolrDocumentSerializer <TestDocWithBoostedString>(mapper, new DefaultFieldSerializer());
            var doc = new TestDocWithBoostedString {
                Desc = "hello"
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal(@"<doc><field name=""Desc"" boost=""1.45"">hello</field></doc>", fs);
        }
Esempio n. 25
0
        public void AcceptsEmptyCollections()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithCollections>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithCollections {
                coll = new string[] { null, null }
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc />", fs);
        }
Esempio n. 26
0
        public void SupportsNullableDateTime()
        {
            var    mapper = new AttributesMappingManager();
            var    ser    = new SolrDocumentSerializer <TestDocWithNullableDate>(mapper, new DefaultFieldSerializer());
            var    doc    = new TestDocWithNullableDate();
            string fs     = ser.Serialize(doc, null).OuterXml;
            var    xml    = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
            Assert.AreEqual("<doc />", fs);
        }
Esempio n. 27
0
        public void SupportsGenericDictionary_empty()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithGenDict>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithGenDict {
                Id   = 5,
                Dict = new Dictionary <string, string>(),
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"Id\">" + doc.Id + "</field></doc>", fs);
        }
Esempio n. 28
0
        public void Inheritance()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithString>(mapper, new DefaultFieldSerializer());
            var doc    = new InheritedDoc {
                Desc  = "Description",
                Desc1 = "Description1"
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal(@"<doc><field name=""Desc1"">Description1</field><field name=""Desc"">Description</field></doc>", fs);
        }
Esempio n. 29
0
        public void SupportsBoolFalse()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithBool>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithBool {
                B = false
            };
            string fs  = ser.Serialize(doc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Assert.AreEqual("<doc><field name=\"B\">false</field></doc>", fs);
        }
 public void DocumentBoost()
 {
     var mapper = new AttributesMappingManager();
     ISolrDocumentSerializer<TestDocWithString> ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithString {
         Desc = "hello"
     };
     string fs = ser.Serialize(doc, 2.1).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
     Assert.AreEqual(@"<doc boost=""2.1""><field name=""Desc"">hello</field></doc>", fs);
 }
Esempio n. 31
0
        public void SupportsDateTime()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithDate>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithDate {
                Date = new DateTime(2001, 1, 2, 3, 4, 5)
            };
            string fs  = ser.Serialize(doc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Assert.AreEqual("<doc><field name=\"Date\">2001-01-02T03:04:05Z</field></doc>", fs);
        }
Esempio n. 32
0
        public void Serializes()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <SampleDoc>(mapper, new DefaultFieldSerializer());
            var doc    = new SampleDoc {
                Id = "id", Dd = 23.5m
            };
            string fs  = ser.Serialize(doc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Assert.AreEqual("<doc><field name=\"Id\">id</field><field name=\"Flower\">23.5</field></doc>", fs);
        }
Esempio n. 33
0
        public void UTF_XML()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithString>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithString {
                Desc = @"ÚóÁ⌠╒"""
            };
            string fs  = ser.Serialize(doc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
            Assert.AreEqual(@"<doc><field name=""Desc"">ÚóÁ⌠╒""</field></doc>", fs);
        }
 public void Inheritance()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
     var doc = new InheritedDoc {
         Desc = "Description",
         Desc1 = "Description1"
     };
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
     Assert.AreEqual(@"<doc><field name=""Desc1"">Description1</field><field name=""Desc"">Description</field></doc>", fs);
 }
Esempio n. 35
0
        public void AcceptsNullObjects()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <SampleDoc>(mapper, new DefaultFieldSerializer());
            var doc    = new SampleDoc {
                Id = null
            };
            string fs = ser.Serialize(doc, null).OuterXml;

            Console.WriteLine(fs);
            var xml = new XmlDocument();

            xml.LoadXml(fs);
        }
Esempio n. 36
0
        public void SupportsGuid()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithGuid>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithGuid {
                Key = Guid.NewGuid()
            };
            string fs  = ser.Serialize(doc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
            Assert.AreEqual("<doc><field name=\"Key\">" + doc.Key + "</field></doc>", fs);
        }
Esempio n. 37
0
        public void DocumentBoost()
        {
            var mapper = new AttributesMappingManager();
            ISolrDocumentSerializer <TestDocWithString> ser = new SolrDocumentSerializer <TestDocWithString>(mapper, new DefaultFieldSerializer());
            var doc = new TestDocWithString {
                Desc = "hello"
            };
            string fs  = ser.Serialize(doc, 2.1).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
            Assert.AreEqual(@"<doc boost=""2.1""><field name=""Desc"">hello</field></doc>", fs);
        }
        public void Location()
        {
            var mapper  = new AttributesMappingManager();
            var ser     = new SolrDocumentSerializer <TestDocWithLocation>(mapper, new DefaultFieldSerializer());
            var testDoc = new TestDocWithLocation {
                Loc = new Location(12.2, -12.3)
            };
            string fs  = ser.Serialize(testDoc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
            Assert.AreEqual(@"<doc><field name=""location"">12.2,-12.3</field></doc>", fs);
        }
Esempio n. 39
0
        public void SupportsGenericDictionary_string_int()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithGenDict2>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithGenDict2 {
                Id   = 5,
                Dict = new Dictionary <string, int> {
                    { "one", 1 },
                    { "two", 2 },
                },
            };
            string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);

            Assert.Equal("<doc><field name=\"Id\">" + doc.Id + "</field><field name=\"Dictone\">1</field><field name=\"Dicttwo\">2</field></doc>", fs);
        }
Esempio n. 40
0
        public void EscapesStrings()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <SampleDoc>(mapper, new DefaultFieldSerializer());
            var doc    = new SampleDoc {
                Id = "<quote\""
            };
            string fs = ser.Serialize(doc, null).OuterXml;

            Console.WriteLine(fs);
            var xml = new XmlDocument();

            xml.LoadXml(fs);
            Assert.AreEqual("<doc><field name=\"Id\">&lt;quote\"</field><field name=\"Flower\">0</field></doc>", fs);
        }
Esempio n. 41
0
        public void Inheritance()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithString>(mapper, new DefaultFieldSerializer());
            var doc    = new InheritedDoc {
                Desc  = "Description",
                Desc1 = "Description1"
            };
            string fs  = ser.Serialize(doc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
            Assert.AreEqual(@"<doc><field name=""Desc1"">Description1</field><field name=""Desc"">Description</field></doc>", fs);
        }
Esempio n. 42
0
        public void SupportsGenericDictionary_empty()
        {
            var mapper = new AttributesMappingManager();
            var ser    = new SolrDocumentSerializer <TestDocWithGenDict>(mapper, new DefaultFieldSerializer());
            var doc    = new TestDocWithGenDict {
                Id   = 5,
                Dict = new Dictionary <string, string>(),
            };
            string fs  = ser.Serialize(doc, null).OuterXml;
            var    xml = new XmlDocument();

            xml.LoadXml(fs);
            Console.WriteLine(fs);
            Assert.AreEqual("<doc><field name=\"Id\">" + doc.Id + "</field></doc>", fs);
        }
 public void SupportsDateTime()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithDate>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithDate {Date = new DateTime(2001, 1, 2, 3, 4, 5)};
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Assert.AreEqual("<doc><field name=\"Date\">2001-01-02T03:04:05Z</field></doc>", fs);
 }
 public void SupportsGenericDictionary_string_string()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithGenDict>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithGenDict {
         Id = 5,
         Dict = new Dictionary<string, string> {
             {"one", "1"},
             {"two", "2"},
         },
     };
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
     Assert.AreEqual("<doc><field name=\"Id\">" + doc.Id + "</field><field name=\"Dictone\">1</field><field name=\"Dicttwo\">2</field></doc>", fs);
 }
 public void SupportsGuid()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithGuid>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithGuid {Key = Guid.NewGuid()};
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
     Assert.AreEqual("<doc><field name=\"Key\">"+doc.Key+"</field></doc>", fs);
 }
 public void SupportsNullableDateTime()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithNullableDate>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithNullableDate();
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
     Assert.AreEqual("<doc />", fs);
 }
 public void UTF_XML()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithString {
         Desc = @"ÚóÁ⌠╒"""
     };
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
     Assert.AreEqual(@"<doc><field name=""Desc"">ÚóÁ⌠╒""</field></doc>", fs);
 }
 public void UTF_XML() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithString {
         Desc = @"ÚóÁ⌠╒"""
     };
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual(@"<doc><field name=""Desc"">ÚóÁ⌠╒""</field></doc>", fs);
 }
 public void Location()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithLocation>(mapper, new DefaultFieldSerializer());
     var testDoc = new TestDocWithLocation { Loc = new Location(12.2, -12.3) };
     string fs = ser.Serialize(testDoc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
     Assert.AreEqual(@"<doc><field name=""location"">12.2,-12.3</field></doc>", fs);
 }
 public void SupportsGenericDictionary_string_int() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithGenDict2>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithGenDict2 {
         Id = 5,
         Dict = new Dictionary<string, int> {
             {"one", 1},
             {"two", 2},
         },
     };
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual("<doc><field name=\"Id\">" + doc.Id + "</field><field name=\"Dictone\">1</field><field name=\"Dicttwo\">2</field></doc>", fs);
 }
 public void SupportsGenericDictionary_empty() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithGenDict>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithGenDict {
         Id = 5,
         Dict = new Dictionary<string, string>(),
     };
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual("<doc><field name=\"Id\">" + doc.Id + "</field></doc>", fs);
 }
 public void SupportsGuid() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithGuid>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithGuid {Key = Guid.NewGuid()};
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual("<doc><field name=\"Key\">"+doc.Key+"</field></doc>", fs);
 }
 public void SupportsGenericDictionary_rest() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithGenDict3>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithGenDict3 {
         Id = 5,
         Dict = new Dictionary<string, object> {
             {"one", 1},
             {"two", 2},
             {"fecha", new DateTime(2010, 1, 1)},
             {"SomeCollection", new[] {"a", "b", "c"}},
         },
     };
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual("<doc><field name=\"Id\">5</field><field name=\"one\">1</field><field name=\"two\">2</field><field name=\"fecha\">2010-01-01T00:00:00Z</field><field name=\"SomeCollection\">a</field><field name=\"SomeCollection\">b</field><field name=\"SomeCollection\">c</field></doc>", fs);
 }
 public void SupportsNullableDateTime() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithNullableDate>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithNullableDate();
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual("<doc />", fs);
 }
 public void SupportsCollections()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithCollections>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithCollections();
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Assert.AreEqual("<doc><field name=\"coll\">one</field><field name=\"coll\">two</field></doc>", fs);
 }
 public void PropertyWithoutGetter() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithoutGetter>(mapper, new DefaultFieldSerializer());
     string fs = ser.Serialize(new TestDocWithoutGetter(), null).ToString();
 }
 public void PropertyWithoutGetter()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithoutGetter>(mapper, new DefaultFieldSerializer());
     string fs = ser.Serialize(new TestDocWithoutGetter(), null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Console.WriteLine(fs);
 }
 public void SupportsBoolFalse()
 {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithBool>(mapper, new DefaultFieldSerializer());
     var doc = new TestDocWithBool {B = false};
     string fs = ser.Serialize(doc, null).OuterXml;
     var xml = new XmlDocument();
     xml.LoadXml(fs);
     Assert.AreEqual("<doc><field name=\"B\">false</field></doc>", fs);
 }
 public void Inheritance() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
     var doc = new InheritedDoc {
         Desc = "Description",
         Desc1 = "Description1"
     };
     string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual(@"<doc><field name=""Desc1"">Description1</field><field name=""Desc"">Description</field></doc>", fs);
 }
 public void Location() {
     var mapper = new AttributesMappingManager();
     var ser = new SolrDocumentSerializer<TestDocWithLocation>(mapper, new DefaultFieldSerializer());
     var testDoc = new TestDocWithLocation { Loc = new Location(12.2, -12.3) };
     string fs = ser.Serialize(testDoc, null).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual(@"<doc><field name=""location"">12.2,-12.3</field></doc>", fs);
 }