public void NoProperties_ShouldReturnEmpty()
        {
            var m      = new AttributesMappingManager();
            var fields = m.GetFields(typeof(NoProperties));

            Assert.AreEqual(0, fields.Count);
        }
 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 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);
 }
Ejemplo n.º 4
0
        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 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 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 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 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 NoProperties_ShouldReturnEmpty()
 {
     var m = new AttributesMappingManager();
     var fields = m.GetFields(typeof (NoProperties));
     Assert.AreEqual(0, fields.Count);
 }
        public void GetFields_WithDuplicatesProperties()
        {
            var m = new AttributesMappingManager();

            Assert.Throws <SolrNetException>(() => m.GetFields(typeof(EntityWithDuplicateFields)).Values);
        }