public void Format_WithExpressionReturningNull_DoesNotThrowException() { //arrange var expr = new FormatExpression("{foo}"); //assert Assert.That(expr.Eval(new { foo = (object)null }), Is.Empty); }
public void Format_WithExpressionReturningNull_ReturnsEmptyString() { //arrange var expr = new FormatExpression("{foo}"); //assert Assert.AreEqual(string.Empty, expr.Eval(new { foo = (string)null })); }
public void Eval_WithNamedExpressionAndFormat_EvalsPropertyOfExpression() { //arrange var expr = new FormatExpression("{foo:#.##}"); //act var result = expr.Eval(new { foo = 1.23456 }); //assert Assert.That(result, Is.EqualTo("1.23")); }
public void Eval_WithNamedExpression_EvalsPropertyOfExpression() { //arrange var expr = new FormatExpression("{foo}"); //act string result = expr.Eval(new { foo = 123 }); //assert Assert.AreEqual("123", result); }
public void Eval_WithNamedExpressionAndFormat_EvalsPropertyOfExpression() { //arrange var expr = new FormatExpression("{foo:#.##}"); //act string result = expr.Eval(new { foo = 1.23456 }); //assert float expected = 1.23f; Assert.AreEqual(expected.ToString(), result); }
static string Eval(string exp) { return(FormatExpression.Eval(new DummyEvaluator(), exp)); }