Esempio n. 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");
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public void No_Mapped_type_returns_empty()
        {
            var mgr    = new MappingManager();
            var fields = mgr.GetFields(typeof(Entity));

            Assert.AreEqual(0, fields.Count);
        }
Esempio n. 4
0
 public void GetFields_doesnt_admit_null()
 {
     Assert.Throws <ArgumentNullException>(() => {
         var mgr = new MappingManager();
         mgr.GetFields(null);
     });
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
        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);
        }
Esempio n. 9
0
        public void GetFields_doesnt_admit_null()
        {
            var mgr = new MappingManager();

            mgr.GetFields(null);
        }