예제 #1
0
        public void ObjectLiteralExpressionHelpersRequireExpression()
        {
            ObjectLiteralExpression expression = null;

            Expect.Throw <ArgumentNullException>(() => expression.WithProperty("name", "value"));
            Expect.Throw <ArgumentNullException>(() => expression.WithProperties(new Dictionary <Expression, Expression>()));
        }
예제 #2
0
        public void ObjectLiteralExpressionHasHelpers()
        {
            var expression = new ObjectLiteralExpression();

            Assert.AreEqual("{};", expression.ToString());

            expression = expression.WithProperty(JS.Id("name"), "value");

            Assert.AreEqual("{name:\"value\"};", expression.ToString());

            expression = expression.WithProperties(new Dictionary <Expression, Expression>
            {
                { JS.Id("key"), "value" },
                { JS.Id("price"), 1200 }
            });

            Assert.AreEqual("{name:\"value\",key:\"value\",price:1200};", expression.ToString());
        }
        public void ObjectLiteralExpressionHasHelpers()
        {
            var expression = new ObjectLiteralExpression();

            Assert.AreEqual("{};", expression.ToString());

            expression = expression.WithProperty(JS.Id("name"), "value");

            Assert.AreEqual("{name:\"value\"};", expression.ToString());

            expression = expression.WithProperties(new Dictionary<Expression, Expression>
            {
                {JS.Id("key"), "value"},
                {JS.Id("price"), 1200}
            });

            Assert.AreEqual("{name:\"value\",key:\"value\",price:1200};", expression.ToString());
        }