forked from SolrNet/SolrNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenericDictionaryDocumentVisitorTests.cs
39 lines (35 loc) · 1.42 KB
/
GenericDictionaryDocumentVisitorTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using MbUnit.Framework;
using SolrNet.Attributes;
using SolrNet.Impl;
using SolrNet.Impl.DocumentPropertyVisitors;
using SolrNet.Impl.FieldParsers;
using SolrNet.Mapping;
using SolrNet.Tests.Utils;
namespace SolrNet.Tests {
[TestFixture]
public class GenericDictionaryDocumentVisitorTests {
[Test]
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);
}
class Entity {
[SolrField("attr_")]
public IDictionary<string, ICollection<int>> Attributes { get; set; }
}
}
}