Пример #1
0
        public void Inherited_gets_id_property_correctly2()
        {
            var mgr = new MappingManager();

            mgr.Add(typeof(InheritedEntity).GetProperty("Id"), "id");

            Assert.IsTrue(mgr.GetFields(typeof(InheritedEntity)).ContainsKey("id"), "InheritedEntity contains id field");
            Assert.IsTrue(mgr.GetFields(typeof(Entity)).ContainsKey("id"), "Entity contains id field");
        }
Пример #2
0
        public void Inherited()
        {
            var mgr = new MappingManager();

            mgr.Add(typeof(Entity).GetProperty("Id"), "id");
            mgr.Add(typeof(InheritedEntity).GetProperty("Description"), "desc");
            var entityFields = mgr.GetFields(typeof(Entity));

            Assert.AreEqual(1, entityFields.Count);
            var inheritedEntityFields = mgr.GetFields(typeof(InheritedEntity));

            Assert.AreEqual(2, inheritedEntityFields.Count);
        }
Пример #3
0
        public void No_Mapped_type_returns_empty()
        {
            var mgr    = new MappingManager();
            var fields = mgr.GetFields(typeof(Entity));

            Assert.AreEqual(0, fields.Count);
        }
Пример #4
0
 public void GetFields_doesnt_admit_null()
 {
     Assert.Throws <ArgumentNullException>(() => {
         var mgr = new MappingManager();
         mgr.GetFields(null);
     });
 }
Пример #5
0
        public void AddAndGet()
        {
            var mgr = new MappingManager();

            mgr.Add(typeof(Entity).GetProperty("Id"), "id");
            var fields = mgr.GetFields(typeof(Entity));

            Assert.AreEqual(1, fields.Count);
        }
Пример #6
0
        public void Add_property_only()
        {
            var mgr      = new MappingManager();
            var property = typeof(Entity).GetProperty("Id");

            mgr.Add(property);
            var fields = mgr.GetFields(typeof(Entity));

            Assert.AreEqual(1, fields.Count);
            Assert.AreEqual("Id", fields.First().Value.FieldName);
        }
Пример #7
0
        public void Add_duplicate_property_overwrites()
        {
            var mgr = new MappingManager();

            mgr.Add(typeof(Entity).GetProperty("Id"), "id");
            mgr.Add(typeof(Entity).GetProperty("Id"), "id2");
            var fields = mgr.GetFields(typeof(Entity));

            Assert.AreEqual(1, fields.Count);
            Assert.AreEqual("id2", fields.First().Value.FieldName);
        }
Пример #8
0
        public void ParseDocumentWithMappingManager()
        {
            var mapper = new MappingManager();

            mapper.Add(typeof(TestDocumentWithoutAttributes).GetProperty("Id"), "id");
            var parser  = new SolrDocumentResponseParser <TestDocumentWithoutAttributes>(mapper, new DefaultDocumentVisitor(mapper, new DefaultFieldParser()), new SolrDocumentActivator <TestDocumentWithoutAttributes>());
            var xml     = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.response.xml");
            var docNode = xml.XPathSelectElement("response/result/doc");
            var doc     = parser.ParseDocument(docNode, mapper.GetFields(typeof(TestDocumentWithoutAttributes)));

            Assert.IsNotNull(doc);
            Assert.AreEqual(123456, doc.Id);
        }
Пример #9
0
        public void GetFields_doesnt_admit_null()
        {
            var mgr = new MappingManager();

            mgr.GetFields(null);
        }