Ejemplo n.º 1
0
        public void GetArgumentSyntax_WhenCreatingWithBinaryExpression_ShouldGetCorrectCode()
        {
            var argument = new LambdaArgument(new ConditionalBinaryExpression(new MemberReference("n"), new MemberReference("true"), ConditionalStatements.Equal).GetBinaryExpression(), "n");
            var syntax   = argument.GetArgumentSyntax();

            Assert.IsInstanceOf <ArgumentSyntax>(syntax);
            Assert.AreEqual("n=>n==true", syntax.ToString());
        }
Ejemplo n.º 2
0
        public void GetArgumentSyntax_WhenCreatingEmptyAsNamedArgument_ShouldGetCorrectCode()
        {
            var argument = new LambdaArgument(Statement.Expression.Invoke("MyMethod").AsExpression(), "n", namedArgument: "namedArgument");
            var syntax   = argument.GetArgumentSyntax();

            Assert.IsInstanceOf <ArgumentSyntax>(syntax);
            Assert.AreEqual("namedArgument:n=>MyMethod()", syntax.ToString());
        }
Ejemplo n.º 3
0
        public void GetArgumentSyntax_WhenCreatingWithWithBlock_ShouldGetCorrectCode()
        {
            var block = BodyGenerator.Create(Statement.Expression.Invoke("MyMethod").AsStatement());

            var argument = new LambdaArgument(block, "n");
            var syntax   = argument.GetArgumentSyntax();

            Assert.IsInstanceOf <ArgumentSyntax>(syntax);
            Assert.AreEqual("n=>{MyMethod();}", syntax.ToString());
        }