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()); }
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()); }
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()); }