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 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\"><quote\"</field><field name=\"Flower\">0</field></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 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.AreEqual("<doc><field name=\"coll\">one</field><field name=\"coll\">two</field></doc>", 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).ToString(SaveOptions.DisableFormatting); Assert.AreEqual("<doc><field name=\"B\">false</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); }
public void Inherited() { var m = new AttributesMappingManager(); var fields = m.GetFields(typeof (InheritedEntity)); Assert.AreEqual(3, fields.Count); var uniqueKey = m.GetUniqueKey(typeof(InheritedEntity)); Assert.IsNotNull(uniqueKey); Assert.AreEqual("Id", uniqueKey.FieldName); }
public void GetUniqueKey() { var m = new AttributesMappingManager(); var key = m.GetUniqueKey(typeof (Entity)); Assert.IsNotNull(key); Assert.IsNotNull(key.Property); Assert.AreEqual("Id", key.Property.Name); Assert.AreEqual("Id", key.FieldName); }
public void ParseResponseWithLocation() { var mapper = new AttributesMappingManager(); var parser = new DefaultResponseParser<Doc>(new SolrDocumentResponseParser<Doc>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator<Doc>())); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.response.xml"); var results = new SolrQueryResults<Doc>(); parser.Parse(xml, results); Assert.AreEqual(1, results.Count); Assert.AreEqual(new Location(51.5171, -0.1062), results[0].Loc); }
public void ReadsMaxScoreAttribute() { var mapper = new AttributesMappingManager(); var innerParser = new ResultsResponseParser <TestDocumentWithArrays4>(new SolrDocumentResponseParser <TestDocumentWithArrays4>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <TestDocumentWithArrays4>())); var parser = new SolrQueryResultParser <TestDocumentWithArrays4>(new[] { innerParser }); var results = parser.Parse(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithArraysSimple.xml")); Assert.AreEqual(1.6578954, results.MaxScore); }
public void Parse() { var mapper = new AttributesMappingManager(); var parser = new CollapseExpandResponseParser<Doc>(new SolrDocumentResponseParser<Doc>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator<Doc>())); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.collapseWithoutExpandResponse.xml"); var results = new SolrQueryResults<Doc>(); parser.Parse(xml, results); Assert.IsNull(results.CollapseExpand); }
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); }
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); }
public void WrongFieldDoesntThrow() { var mapper = new AttributesMappingManager(); var innerParser = new ResultsResponseParser <TestDocumentWithDate>(new SolrDocumentResponseParser <TestDocumentWithDate>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <TestDocumentWithDate>())); var parser = new SolrQueryResultParser <TestDocumentWithDate>(new[] { innerParser }); var results = parser.Parse(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithArraysSimple.xml")); Assert.AreEqual(1, results.Count); var doc = results[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); }
public void DifferentTypes() { var m = new AttributesMappingManager(); var key = m.GetUniqueKey(typeof(Entity)); Assert.IsNotNull(key); Assert.IsNotNull(key.Property); Assert.AreEqual("Id", key.Property.Name); Assert.AreEqual("Id", key.FieldName); var fields = m.GetFields(typeof (AnotherEntity)); Assert.AreEqual(1, fields.Count); }
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 Parse_If_Both_Result_And_Groups_Are_Present() { var mapper = new AttributesMappingManager(); var parser = new DefaultResponseParser<TestDoc>(new SolrDocumentResponseParser<TestDoc>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator<TestDoc>())); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithResultAndGroup.xml"); var results = new SolrQueryResults<TestDoc>(); parser.Parse(xml, results); Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results.Grouping["titleId"].Ngroups); }
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 GetRegisteredTypes() { var m = new AttributesMappingManager(); var types = m.GetRegisteredTypes(); Assert.GreaterThan(types.Count, 0); Assert.Contains(types, typeof(Entity)); Assert.Contains(types, typeof(InheritedEntity)); Assert.Contains(types, typeof(AnotherEntity)); Assert.DoesNotContain(types, typeof(NoProperties)); }
public void GetRegisteredTypes() { var m = new AttributesMappingManager(); var types = m.GetRegisteredTypes(); Assert.That(types.Count, Is.GreaterThan(0)); Assert.That(types, Contains.Item(typeof(Entity))); Assert.That(types, Contains.Item(typeof(InheritedEntity))); Assert.That(types, Contains.Item(typeof(AnotherEntity))); Assert.That(types, !Contains.Item(typeof(NoProperties))); }
public void Parse() { var mapper = new AttributesMappingManager(); var parser = new CollapseExpandResponseParser <Doc>(new SolrDocumentResponseParser <Doc>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <Doc>())); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.collapseWithoutExpandResponse.xml"); var results = new SolrQueryResults <Doc>(); parser.Parse(xml, results); Assert.Null(results.CollapseExpand); }
public void GetUniqueKey() { var m = new AttributesMappingManager(); var key = m.GetUniqueKey(typeof(Entity)); Assert.IsNotNull(key); Assert.IsNotNull(key.Property); Assert.AreEqual("Id", key.Property.Name); Assert.AreEqual("Id", key.FieldName); }
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 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 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 GetRegisteredTypes() { var m = new AttributesMappingManager(); var types = m.GetRegisteredTypes(); Assert.True(types.Count > 0); Assert.Contains(typeof(Entity), types); Assert.Contains(typeof(InheritedEntity), types); Assert.Contains(typeof(AnotherEntity), types); Assert.DoesNotContain(typeof(NoProperties), types); }
public void ParseResultsWithGroups() { var mapper = new AttributesMappingManager(); var innerParser = new GroupingResponseParser <Product>(new SolrDocumentResponseParser <Product>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <Product>())); var parser = new SolrQueryResultParser <Product>(new[] { innerParser }); var results = parser.Parse(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.responseWithGroupingOnInstock.xml")); Assert.AreEqual(1, results.Grouping.Count); Assert.AreEqual(2, results.Grouping["inStock"].Groups.Count()); Assert.AreEqual(13, results.Grouping["inStock"].Groups.First().NumFound); }
public void GetRegisteredTypes() { var m = new AttributesMappingManager(); var types = m.GetRegisteredTypes(); Assert.Greater(types.Count, 0); CollectionAssert.Contains(types, typeof(Entity)); CollectionAssert.Contains(types, typeof(InheritedEntity)); CollectionAssert.Contains(types, typeof(AnotherEntity)); CollectionAssert.DoesNotContain(types, typeof(NoProperties)); }
public void Inherited() { var m = new AttributesMappingManager(); var fields = m.GetFields(typeof(InheritedEntity)); Assert.AreEqual(3, fields.Count); var uniqueKey = m.GetUniqueKey(typeof(InheritedEntity)); Assert.IsNotNull(uniqueKey); Assert.AreEqual("Id", uniqueKey.FieldName); }
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\"><quote\"</field><field name=\"Flower\">0</field></doc>", fs); }
public void Parse() { var mapper = new AttributesMappingManager(); var fieldParser = new DefaultFieldParser(); var docVisitor = new DefaultDocumentVisitor(mapper, fieldParser); var docParser = new SolrDocumentResponseParser<Product>(mapper, docVisitor, new SolrDocumentActivator<Product>()); var p = new MoreLikeThisHandlerMatchResponseParser<Product>(docParser); var mltResults = new SolrMoreLikeThisHandlerResults<Product>(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithMLTHandlerMatch.xml"); p.Parse(xml, mltResults); Assert.IsNotNull(mltResults.Match); }
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); }
public void Parse_If_Both_Result_And_Groups_Are_Present() { var mapper = new AttributesMappingManager(); var parser = new DefaultResponseParser <TestDoc>(new SolrDocumentResponseParser <TestDoc>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <TestDoc>())); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithResultAndGroup.xml"); var results = new SolrQueryResults <TestDoc>(); parser.Parse(xml, results); Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results.Grouping["titleId"].Ngroups); }
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); }
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); }
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 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); }
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); }
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); }
public void ParseResponseWithLocation() { var mapper = new AttributesMappingManager(); var parser = new DefaultResponseParser <Doc>(new SolrDocumentResponseParser <Doc>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <Doc>())); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.response.xml"); var results = new SolrQueryResults <Doc>(); parser.Parse(xml, results); Assert.AreEqual(1, results.Count); Assert.AreEqual(new Location(51.5171, -0.1062), results[0].Loc); }
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\"><quote\"</field><field name=\"Flower\">0</field></doc>", fs); }
public void PropertyWithoutSetter() { var mapper = new AttributesMappingManager(); var parser = new SolrDocumentResponseParser <TestDocWithoutSetter>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <TestDocWithoutSetter>()); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.response.xml"); var docNode = xml.XPathSelectElement("response/result/doc"); var doc = parser.ParseDocument(docNode, mapper.GetFields(typeof(TestDocument))); Assert.IsNotNull(doc); Assert.AreEqual(0, doc.Id); }
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 SetPropertyNullableDouble() { var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.responseWithArrays.xml"); var fieldNode = xml.XPathSelectElement("response/result/doc/float[@name='price']"); var mapper = new AttributesMappingManager(); var visitor = new DefaultDocumentVisitor(mapper, new DefaultFieldParser()); var doc = new TestDocumentWithNullableDouble(); visitor.Visit(doc, "price", fieldNode); Assert.AreEqual(92d, doc.Price); }
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); }
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); }
public void Parse() { var mapper = new AttributesMappingManager(); var innerParser = new ResultsResponseParser <TestDocument>(new SolrDocumentResponseParser <TestDocument>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <TestDocument>())); var parser = new SolrQueryResultParser <TestDocument>(new[] { innerParser }); var results = parser.Parse(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml")); Assert.AreEqual(1, results.Count); var doc = results[0]; Assert.AreEqual(123456, doc.Id); }
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); }
public void GetFields() { var m = new AttributesMappingManager(); var fields = m.GetFields(typeof (Entity)).Values; Assert.AreEqual(2, fields.Count); foreach (var f in fields) { if (f.FieldName == "Id") Assert.AreEqual("Id", f.Property.Name); else if (f.FieldName == "desc") Assert.AreEqual("Description", f.Property.Name); else Assert.Fail("Invalid field '{0}'", f.FieldName); } }
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 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); }
public void Parse2() { var mapper = new AttributesMappingManager(); var parser = new CollapseExpandResponseParser<Doc>(new SolrDocumentResponseParser<Doc>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator<Doc>())); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.collapseWithExpandResponse.xml"); var results = new SolrQueryResults<Doc>(); parser.Parse(xml, results); Assert.IsNotNull(results.CollapseExpand); Assert.AreEqual(4, results.CollapseExpand.Groups.Count); var group = results.CollapseExpand.Groups.ElementAt(0); Assert.AreEqual(group.Documents.Count, 2); Assert.AreEqual(group.GroupValue, "First"); Assert.AreEqual(group.NumFound, 2); }
public void ParseDictionaryOfCollection() { var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.docWithDynamicFields.xml"); var mapper = new AttributesMappingManager(); var parser = new SolrDocumentResponseParser<Entity>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator<Entity>()); var entity = parser.ParseDocument(xml.Root); Assert.IsNotNull(entity, "entity was null"); Assert.IsNotNull(entity.Attributes, "attributes was null"); Assert.AreEqual(16, entity.Attributes.Count); var attr2 = entity.Attributes["2"]; Assert.AreEqual(5, attr2.Count); Assert.Contains(attr2, 63); Assert.Contains(attr2, 64); Assert.Contains(attr2, 65); Assert.Contains(attr2, 66); Assert.Contains(attr2, 102); }
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 PropertyWithoutGetter() { var mapper = new AttributesMappingManager(); var ser = new SolrDocumentSerializer<TestDocWithoutGetter>(mapper, new DefaultFieldSerializer()); string fs = ser.Serialize(new TestDocWithoutGetter(), null).ToString(); }
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 NullableDateTime() { var mocks = new MockRepository(); var connection = mocks.StrictMock<ISolrConnection>(); var responseParser = mocks.DynamicMock<ISolrHeaderResponseParser>(); var resultParser = mocks.StrictMock<ISolrQueryResultParser<TestDocWithNullable>>(); var queryExecuter = new SolrQueryExecuter<TestDocWithNullable>(resultParser, connection, null, null); var mapper = new AttributesMappingManager(); var docSerializer = new SolrDocumentSerializer<TestDocWithNullable>(mapper, new DefaultFieldSerializer()); var validationManager = mocks.StrictMock<IMappingValidator>(); var basicSolr = new SolrBasicServer<TestDocWithNullable>(connection, queryExecuter, docSerializer, null, responseParser, null, null, null); var solr = new SolrServer<TestDocWithNullable>(basicSolr, mapper, validationManager); string xml = null; With.Mocks(mocks) .Expecting(() => { Expect.On(connection) .Call(connection.Post(null, null)) .IgnoreArguments() .Do(new Writer(delegate(string u, string s) { Console.WriteLine(s); xml = s; return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml"); })); }) .Verify(() => { solr.Add(new TestDocWithNullable()); Assert.AreEqual("<add><doc /></add>", xml); }); }
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); }