Calling an indexer with more than one argument gives a parse exception on the list separator.
Unit tests:
[TestMethod]
public void TestIndexerWithOneArgument() {
ExpressionContext context = new ExpressionContext(new IndexerContainer());
IGenericExpression<string> expr = ExpressionFactory.CreateGeneric<string>("Indexer[\"Bob\"]", context);
Assert.AreEqual("name : Bob, selected : False", expr.Evaluate());
}
[TestMethod]
public void TestIndexerWithTwoArguments() {
ExpressionContext context = new ExpressionContext(new IndexerContainer());
IGenericExpression<string> expr = ExpressionFactory.CreateGeneric<string>("Indexer[\"Bob\"; true]", context);
Assert.AreEqual("name : Bob, selected : True", expr.Evaluate());
}
public class IndexerContainer {
public IndexerClass Indexer = new IndexerClass();
}
public class IndexerClass {
public string this[string name] {
get {
return this[name, false];
}
}
public string this[string name, bool isSelected] {
get {
return string.Format("name : {0}, selected : {1}", name, isSelected);
}
}
}
The first test succeeds, the second fails. I think it should succeed.
Can you have a look at the issue? Thanks!
BTW: I'm running these tests with a Dutch current culture, so I used ';' as list separator.
Unit tests:
[TestMethod]
public void TestIndexerWithOneArgument() {
ExpressionContext context = new ExpressionContext(new IndexerContainer());
IGenericExpression<string> expr = ExpressionFactory.CreateGeneric<string>("Indexer[\"Bob\"]", context);
Assert.AreEqual("name : Bob, selected : False", expr.Evaluate());
}
[TestMethod]
public void TestIndexerWithTwoArguments() {
ExpressionContext context = new ExpressionContext(new IndexerContainer());
IGenericExpression<string> expr = ExpressionFactory.CreateGeneric<string>("Indexer[\"Bob\"; true]", context);
Assert.AreEqual("name : Bob, selected : True", expr.Evaluate());
}
public class IndexerContainer {
public IndexerClass Indexer = new IndexerClass();
}
public class IndexerClass {
public string this[string name] {
get {
return this[name, false];
}
}
public string this[string name, bool isSelected] {
get {
return string.Format("name : {0}, selected : {1}", name, isSelected);
}
}
}
The first test succeeds, the second fails. I think it should succeed.
Can you have a look at the issue? Thanks!
BTW: I'm running these tests with a Dutch current culture, so I used ';' as list separator.