public void SortType_Complex() { var valueTypeConverter = new SampleConverter(); mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Complex"), StoreMode.Yes, valueTypeConverter, TypeDescriptor.GetConverter(typeof(int)), "Complex", 128, 1.0f); Assert.That(mapper.CreateSortField(false).Type, Is.EqualTo(SortField.INT)); }
public void ConvertsFieldValue() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Int"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Int", 128, 1.0f); var result = mapper.ConvertFieldValue(new Field("Int", "100", Field.Store.YES, Field.Index.NO)); Assert.That(result, Is.EqualTo(100)); }
public void ConvertsFieldValue() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Int"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Int", 128, 1.0f); var result = mapper.ConvertFieldValue(new Field("Int", "100", Field.Store.YES, Field.Index.NO)); Assert.That(result, Is.EqualTo(100)); }
public void ConvertsNullable() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("NullableLong"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "NullableLong", 128, 1.0f); var result = mapper.ConvertToQueryExpression(123L); Assert.That(result, Is.EqualTo(123L.ToPrefixCoded())); }
public void RangeQueryUnbounded() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Long", 128, 1.0f); var result = mapper.CreateRangeQuery(100L, null, RangeType.Exclusive, RangeType.Inclusive); Assert.That(result, Is.InstanceOf <NumericRangeQuery <long> >()); Assert.That(result.ToString(), Is.EqualTo(string.Format("Long:{{100 TO {0}]", long.MaxValue))); }
public void RangeQuery() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Long", 128, 1.0f); var result = mapper.CreateRangeQuery(-5L, 5L, RangeType.Inclusive, RangeType.Exclusive); Assert.That(result, Is.InstanceOf <NumericRangeQuery <long> >()); Assert.That(result.ToString(), Is.EqualTo("Long:[-5 TO 5}")); }
public void ConvertsFieldValueToNonValueType() { var valueTypeConverter = new SampleConverter(); mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Complex"), StoreMode.Yes, valueTypeConverter, TypeDescriptor.GetConverter(typeof(int)), "Complex", 128, 1.0f); var result = mapper.ConvertFieldValue(new Field("Complex", "100", Field.Store.YES, Field.Index.NO)); Assert.That(result, Is.InstanceOf <Complex>()); }
public void ConvertsFieldValueToNonValueType() { var valueTypeConverter = new SampleConverter(); mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Complex"), StoreMode.Yes, valueTypeConverter, TypeDescriptor.GetConverter(typeof(int)), "Complex", 128, 1.0f); var result = mapper.ConvertFieldValue(new Field("Complex", "100", Field.Store.YES, Field.Index.NO)); Assert.That(result, Is.InstanceOf<Complex>()); }
public void UsesPrecisionStep() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Int"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Int", 128, 1.0f); var sample = new Sample { Long = 1234L }; var document = new Document(); mapper.CopyToDocument(sample, document); var field = document.GetFieldable("Int"); Assert.That(field.TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=32,precisionStep=128)")); }
public void StoreLong() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(long)), "Long", NumericUtils.PRECISION_STEP_DEFAULT, 1.0f); var sample = new Sample { Long = 1234L }; var document = new Document(); mapper.CopyToDocument(sample, document); var field = document.GetFieldable("Long"); Assert.That(field.TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=64,precisionStep=4)")); }
public void StoreLong() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(long)), "Long", NumericUtils.PRECISION_STEP_DEFAULT, 1.0f); var sample = new Sample { Long = 1234L }; var document = new Document(); mapper.CopyToDocument(sample, document); var field = document.GetFieldable("Long"); Assert.That(field.TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=64,precisionStep=4)")); }
public void UsesPrecisionStep() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Int"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Int", 128, 1.0f); var sample = new Sample { Long = 1234L }; var document = new Document(); mapper.CopyToDocument(sample, document); var field = document.GetFieldable("Int"); Assert.That(field.TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=32,precisionStep=128)")); }
public void SortType_Int() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Int"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Int", 128, 1.0f); Assert.That(mapper.CreateSortField(false).Type, Is.EqualTo(SortField.INT)); }
public void SortType_Long() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(long)), "Long", NumericUtils.PRECISION_STEP_DEFAULT, 1.0f); Assert.That(mapper.CreateSortField(false).Type, Is.EqualTo(SortField.LONG)); }
public void RangeQueryUnbounded() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Long", 128, 1.0f); var result = mapper.CreateRangeQuery(100L, null, RangeType.Exclusive, RangeType.Inclusive); Assert.That(result, Is.InstanceOf<NumericRangeQuery<long>>()); Assert.That(result.ToString(), Is.EqualTo(string.Format("Long:{{100 TO {0}]", long.MaxValue))); }
public void RangeQuery() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Long", 128, 1.0f); var result = mapper.CreateRangeQuery(-5L, 5L, RangeType.Inclusive, RangeType.Exclusive); Assert.That(result, Is.InstanceOf<NumericRangeQuery<long>>()); Assert.That(result.ToString(), Is.EqualTo("Long:[-5 TO 5}")); }
public void ConvertsNullable() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("NullableLong"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "NullableLong", 128, 1.0f); var result = mapper.ConvertToQueryExpression(123L); Assert.That(result, Is.EqualTo(123L.ToPrefixCoded())); }
public void SortType_Long() { mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Long"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(long)), "Long", NumericUtils.PRECISION_STEP_DEFAULT, 1.0f); Assert.That(mapper.CreateSortField(false).Type, Is.EqualTo(SortField.LONG)); }
public void SortType_Complex() { var valueTypeConverter = new SampleConverter(); mapper = new NumericReflectionFieldMapper<Sample>(typeof(Sample).GetProperty("Complex"), StoreMode.Yes, valueTypeConverter, TypeDescriptor.GetConverter(typeof(int)), "Complex", 128, 1.0f); Assert.That(mapper.CreateSortField(false).Type, Is.EqualTo(SortField.INT)); }
public void SortType_Int() { mapper = new NumericReflectionFieldMapper <Sample>(typeof(Sample).GetProperty("Int"), StoreMode.Yes, null, TypeDescriptor.GetConverter(typeof(int)), "Int", 128, 1.0f); Assert.That(mapper.CreateSortField(false).Type, Is.EqualTo(SortField.INT)); }