Exemplo n.º 1
0
        public void BuildFromComplexTypeWithCustomConverter()
        {
            var propertyInfo = GetType().GetProperty("ComplexPropertyWithConverter");
            var context      = (ReflectionFieldMapper <FieldMappingInfoBuilderTests>)FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(propertyInfo);

            Assert.That(context.Converter, Is.InstanceOf <ComplexTypeConverter>());
        }
Exemplo n.º 2
0
        public void BuildFromIntProperty()
        {
            var propertyInfo = GetType().GetProperty("IntProperty");
            var context      = (ReflectionFieldMapper <FieldMappingInfoBuilderTests>)FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(propertyInfo);

            Assert.That(context.Converter, Is.InstanceOf <Int32Converter>());
        }
Exemplo n.º 3
0
        public void BuildThrowsOnUnconvertableType()
        {
            var          propertyInfo = GetType().GetProperty("ComplexProperty");
            TestDelegate call         = () => FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(propertyInfo);

            Assert.That(call, Throws.Exception.InstanceOf <NotSupportedException>());
        }
Exemplo n.º 4
0
        public void OverrideFieldName()
        {
            var propertyInfo = GetType().GetProperty("FriendlyName");
            var context      = FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(propertyInfo);

            Assert.That(context.FieldName, Is.EqualTo("ugly_lucene_field_name"));
        }
        public void BuildFromIntProperty()
        {
            var propertyInfo = GetType().GetProperty("IntProperty");
            var context      = FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(propertyInfo);

            Assert.That(context.Converter, Is.EqualTo(TypeDescriptor.GetConverter(typeof(int))));
        }
Exemplo n.º 6
0
        public void RetainsPropertyInfo()
        {
            var context = (ReflectionFieldMapper <FieldMappingInfoBuilderTests>)FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(stringPropertyInfo);

            Assert.That(context.PropertyName, Is.EqualTo(stringPropertyInfo.Name));
            Assert.That(context.PropertyInfo, Is.EqualTo(stringPropertyInfo));
        }
Exemplo n.º 7
0
        public void CaseSensitive_WhenPropertySet()
        {
            var flag = FieldMappingInfoBuilder.GetCaseSensitivity(new FieldAttribute {
                CaseSensitive = true
            }, null);

            Assert.That(flag, Is.True);
        }
Exemplo n.º 8
0
        public void CaseSensitive_IndexMode_NotAnalyzedNoNorms()
        {
            var flag = FieldMappingInfoBuilder.GetCaseSensitivity(new FieldAttribute(IndexMode.NotAnalyzedNoNorms)
            {
                CaseSensitive = false
            }, null);

            Assert.That(flag, Is.True);
        }
Exemplo n.º 9
0
 private ReflectionFieldMapper <FieldMappingInfoBuilderAnalyzerTests> Build(string propertyName)
 {
     return((ReflectionFieldMapper <FieldMappingInfoBuilderAnalyzerTests>)FieldMappingInfoBuilder
            .Build <FieldMappingInfoBuilderAnalyzerTests>(
                GetType()
                .GetProperty(propertyName),
                Version.LUCENE_30,
                null));
 }
Exemplo n.º 10
0
        protected internal virtual IFieldMapper <T> ToFieldMapper()
        {
            var mapper = ToFieldMapperInternal();

            Type type;

            if (FieldMappingInfoBuilder.IsCollection(propInfo.PropertyType, out type))
            {
                return(new CollectionReflectionFieldMapper <T>(mapper, type));
            }

            return(mapper);
        }
Exemplo n.º 11
0
        private TypeConverter ResolveConverter()
        {
            if (converter != null)
            {
                return(converter);
            }

            var fakeAttr = new FieldAttribute(indexMode)
            {
                CaseSensitive = caseSensitive
            };

            return(FieldMappingInfoBuilder.GetConverter(propInfo, PropertyType, fakeAttr));
        }
Exemplo n.º 12
0
        private Analyzer ResolveAnalyzer()
        {
            if (analyzer != null)
            {
                return(analyzer);
            }

            var fakeAttr = new FieldAttribute(indexMode)
            {
                CaseSensitive = caseSensitive
            };

            var flag = FieldMappingInfoBuilder.GetCaseSensitivity(fakeAttr, converter);

            return(flag ? new KeywordAnalyzer() : new CaseInsensitiveKeywordAnalyzer());
        }
Exemplo n.º 13
0
        public void CaseSensitive_False()
        {
            var flag = FieldMappingInfoBuilder.GetCaseSensitivity(new FieldAttribute(), null);

            Assert.That(flag, Is.False);
        }
 private IFieldMapper <FieldMappingInfoBuilderCollectionComplexTypeTests> CreateMapper()
 {
     return(FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderCollectionComplexTypeTests>(info));
 }
 private IFieldMapper <FieldMappingInfoBuilderScoreTests> CreateMapper()
 {
     return(FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderScoreTests>(info));
 }
Exemplo n.º 16
0
        public void AnalyzerMustHavePublicCtr()
        {
            TestDelegate call = () => FieldMappingInfoBuilder.CreateAnalyzer(typeof(Private), Version.LUCENE_30);

            Assert.That(call, Throws.InvalidOperationException);
        }
Exemplo n.º 17
0
        public void AnalyzerMustInheritFromBase()
        {
            TestDelegate call = () => FieldMappingInfoBuilder.CreateAnalyzer(typeof(object), Version.LUCENE_30);

            Assert.That(call, Throws.InvalidOperationException);
        }
Exemplo n.º 18
0
        public void UsesExternalAnalyzerWhenProvided()
        {
            var externalAnalyzer = new StandardAnalyzer(Version.LUCENE_30);

            var mapper = (ReflectionFieldMapper <FieldMappingInfoBuilderAnalyzerTests>)FieldMappingInfoBuilder
                         .Build <FieldMappingInfoBuilderAnalyzerTests>(
                GetType().GetProperty("Simple"),
                Version.LUCENE_30,
                externalAnalyzer);

            Assert.That(mapper.Analyzer, Is.SameAs(externalAnalyzer));
        }
Exemplo n.º 19
0
        public void NoConverterForStrings()
        {
            var context = (ReflectionFieldMapper <FieldMappingInfoBuilderTests>)FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(stringPropertyInfo);

            Assert.That(context.Converter, Is.Null, "No converter should be necessary for typeof(string)");
        }
 private IFieldMapper <FieldMappingInfoBuilderSortFieldTests> CreateMapper(PropertyInfo propertyInfo)
 {
     return(FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderSortFieldTests>(propertyInfo));
 }
        public void RetainsPropertyInfo()
        {
            var context = FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(stringPropertyInfo);

            Assert.That(context.PropertyInfo, Is.SameAs(stringPropertyInfo));
        }
 private IFieldMapper <FieldMappingInfoBuilderDateFormatTests> CreateMapper(string propertyName, out PropertyInfo info)
 {
     info = GetType().GetProperty(propertyName);
     return(FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderDateFormatTests>(info));
 }
        private IFieldMapper <FieldMappingInfoBuilderDateFormatTests> CreateMapper <T>(Expression <Func <T> > expression)
        {
            var info = ((MemberExpression)expression.Body).Member;

            return(FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderDateFormatTests>((PropertyInfo)info));
        }
Exemplo n.º 24
0
        public void CaseSensitive_NullMetadata_False()
        {
            var flag = FieldMappingInfoBuilder.GetCaseSensitivity(null, null);

            Assert.That(flag, Is.False);
        }
 private IFieldMapper <FieldMappingInfoBuilderNumericDateTimeTests> CreateMapper()
 {
     return(FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderNumericDateTimeTests>(info));
 }
Exemplo n.º 26
0
        public void FieldIsPropertyName()
        {
            var context = FieldMappingInfoBuilder.Build <FieldMappingInfoBuilderTests>(stringPropertyInfo);

            Assert.That(context.FieldName, Is.EqualTo(stringPropertyInfo.Name));
        }