Exemplo n.º 1
0
        public void Format_WithoutColon_ReadsWholeExpression()
        {
            //arrange
            var expr = new FormatExpression("{foo}");

            //assert
            Assert.AreEqual("foo", expr.Expression);
        }
Exemplo n.º 2
0
        public void Format_WithExpressionReturningNull_ReturnsEmptyString()
        {
            //arrange
            var expr = new FormatExpression("{foo}");

            //assert
            Assert.AreEqual(string.Empty, expr.Eval(new {foo = (string)null}));
        }
Exemplo n.º 3
0
        public void Format_WithColon_ParsesoutFormat()
        {
            //arrange
            var expr = new FormatExpression("{foo:#.##}");

            //assert
            Assert.AreEqual("#.##", expr.Format);
        }
Exemplo n.º 4
0
        public void Eval_WithNamedExpression_EvalsPropertyOfExpression()
        {
            //arrange
            var expr = new FormatExpression("{foo}");

            //act
            string result = expr.Eval(new {foo = 123});

            //assert
            Assert.AreEqual("123", result);
        }
Exemplo n.º 5
0
        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);
        }