chriseldredge / Lucene.Net.Linq

LINQ provider to run native queries on a Lucene.Net index
Other
151 stars 65 forks source link

Mapping of System.Double not working #21

Closed dittodhole closed 11 years ago

dittodhole commented 11 years ago

You have two test-methods, which actually fail on systems with german culture:

  String lengths are both 4. Strings differ at index 1.
  Expected: "1.34"
  But was:  "1,34"
  ------------^

I suppose you somehow inject an invariant CultureInfo-instance (or by attribution) into your reflection based mapping.

dittodhole commented 11 years ago

Also ... shouldn't your test FieldMappingInfoBuilderNumericFieldTests.CopyToDocument be restated as:

    [Test]
    public void CopyToDocument()
    {
        const double theValue = 1.34d;
        CustomValueType = new SampleValueType
        {
            TheValue = theValue
        };
        var mapper = CreateMapper();

        var doc = new Document();

        mapper.CopyToDocument(this, doc);

        Assert.That(doc.GetFieldable("CustomValueType").TokenStreamValue.ToString(), Is.EqualTo("(numeric,valSize=64,precisionStep=4)"));
        Assert.That(doc.GetFieldable("CustomValueType").StringValue, Is.EqualTo(theValue.ToString()));
    }

This style of number-formatting may also apply to the other test-method...

chriseldredge commented 11 years ago

Fixed in 690e01a89a4df7d61ea4470858d343e1287fa018 using suggested method.