Skip to content

Commit

Permalink
Money integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mausch committed Jul 26, 2012
1 parent 7bf309f commit 2321d4d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion SolrNet.Tests/Integration.Sample/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public class Product {
[SolrField("timestamp")]
public DateTime Timestamp { get; set; }

[SolrField("price_")]
[SolrField("price_c")]
public Money PriceMoney { get; set; }

[SolrField("value_")]
public IDictionary<string, decimal> Prices { get; set; }

[SolrField("ca")]
Expand Down
14 changes: 14 additions & 0 deletions SolrNet.Tests/Integration.Sample/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void Add_then_query() {
{"afterrebate", 100m},
},
Price = 92,
PriceMoney = new Money(92m, "USD"),
Popularity = 6,
InStock = true,
DynCategories = new Dictionary<string, ICollection<string>> {
Expand Down Expand Up @@ -120,6 +121,7 @@ public void Add_then_query() {
{"afterrebate", 100m},
},
Price = 92,
PriceMoney = new Money(123.44m, "EUR"),
Popularity = 6,
InStock = false,
},
Expand All @@ -140,6 +142,7 @@ public void Add_then_query() {
{"afterrebate", 100m},
},
Price = 92,
PriceMoney = new Money(123.44m, "ARS"),
Popularity = 6,
InStock = false,
},
Expand All @@ -160,11 +163,22 @@ public void Add_then_query() {
{"afterrebate", 100m},
},
Price = 92,
PriceMoney = new Money(123.44m, "GBP"),
Popularity = 6,
InStock = false,
}
};

[Test]
public void QueryByRangeMoney() {
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
solr.AddRange(products);
solr.Commit();

var results = solr.Query(new SolrQueryByRange<Money>("price_c", new Money(123, null), new Money(3000, "USD")));
Assert.AreEqual(2, results.Count);
}

[Test]
public void DeleteByIdAndOrQuery() {
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
Expand Down
5 changes: 1 addition & 4 deletions solr/solr/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<dynamicField name="attr_*" type="text_general" indexed="true" stored="true" multiValued="true"/>

<dynamicField name="random_*" type="random" />
<dynamicField name="price_*" type="float" indexed="true" stored="true"/>
<dynamicField name="value_*" type="float" indexed="true" stored="true"/>

<!-- uncomment the following to ignore any fields that don't already match an existing
field name or dynamic field, rather than reporting them as an error.
Expand Down Expand Up @@ -234,9 +234,6 @@
<copyField source="features" dest="text"/>
<copyField source="includes" dest="text"/>
<copyField source="manu" dest="manu_exact"/>

<!-- Copy the price into a currency enabled field (default USD) -->
<copyField source="price" dest="price_c"/>

<!-- Above, multiple source fields are copied to the [text] field.
Another way to map multiple source fields to the same
Expand Down

0 comments on commit 2321d4d

Please sign in to comment.