Investigate and resolve broken unit tests
Closed this issue · 0 comments
bijington commented
Is appears that during the recent round of refactoring the following unit tests have stopped passing. Investigate each one and either fix or verify if they are really needed ahead of the upcoming release.
[TestMethod]
public void ShouldEvaluateSubExpressions()
{
var volume = new Expression("[surface] * [h]");
var surface = new Expression("[l] * [K]");
Assert.AreEqual(6, volume.Evaluate(new Dictionary<string, object> { { "surface", surface }, { "h", 3 }, { "l", 1 }, { "K", 2 } }));
}
[TestMethod]
public void ShouldHandleBugTwentyTwo()
{
// Not working
//[myDouble]*5
//[myDouble]* pow(5.5,2)
//[myDouble]+5.5
var arguments = new Dictionary<string, object>
{
["myDouble"] = 4.0,
["myFloat"] = 4.0f
};
var expression = new Expression("[myDouble]*5");
Assert.AreEqual(20, (double)expression.Evaluate(arguments));
expression = new Expression("[myDouble]*Pow(5.5,2)");
Assert.AreEqual(121, (double)expression.Evaluate(arguments));
expression = new Expression("[myDouble]+5.5");
Assert.AreEqual(9.5M, (decimal)expression.Evaluate(arguments));
// Not working
//[myDouble]*5.5
expression = new Expression("[myDouble]*5.5");
Assert.AreEqual(22M, (decimal)expression.Evaluate(arguments));
expression = new Expression("[myDouble]-5.5");
Assert.AreEqual(-1.5M, (decimal)expression.Evaluate(arguments));
expression = new Expression("[myDouble]+5.5");
Assert.AreEqual(9.5M, (decimal)expression.Evaluate(arguments));
expression = new Expression("[myDouble]/2.0");
Assert.AreEqual(2.0M, (decimal)expression.Evaluate(arguments));
expression = new Expression("[myFloat]/2.0");
Assert.AreEqual(2.0M, (decimal)expression.Evaluate(arguments));
}
[TestMethod]
public void ShouldHandleOperatorsPriority()
{
Assert.AreEqual(8, new Expression("2+2+2+2").Evaluate());
Assert.AreEqual(16, new Expression("2*2*2*2").Evaluate());
Assert.AreEqual(6, new Expression("2*2+2").Evaluate());
Assert.AreEqual(6, new Expression("2+2*2").Evaluate());
Assert.AreEqual(9d, new Expression("1 + 2 + 3 * 4 / 2").Evaluate());
Assert.AreEqual(13.5M, new Expression("18.0/2.0/2.0*3.0").Evaluate());
}