public void TheStringVariable() { var theVariable = "theValue"; var actual = ExpressionWithValue.ToValuedCode(() => theVariable); Assert.AreEqual("theVariable = theValue", actual); }
public void ArrayLength() { var arr = new[] { 1 }; var actual = ExpressionWithValue.ToValuedCode(() => arr.Length); Assert.AreEqual("arr.Length = 1", actual); }
public void ToValuedCode_ofNull_fails() { ExpressionToCodeTest obj = null; Assert.Catch <InvalidOperationException>( () => ExpressionWithValue.ToValuedCode(() => obj.TheProperty)); }
public void ThisStaticMethodCall() { var code = ExpressionWithValue.ToValuedCode(() => StaticReturnZero()); Assert.AreEqual("ToValuedCodeTest.StaticReturnZero() = 0", code); }
public void ThisMethodCall() { var code = ExpressionWithValue.ToValuedCode(() => ReturnZero()); Assert.AreEqual("ReturnZero() = 0", code); }
public void ThisIndexedProperty() { var actual = ExpressionWithValue.ToValuedCode(() => this[1]); Assert.AreEqual("ToValuedCodeTest[1] = TheIndexedValue", actual); }
public void TheGenericMethod() { var actual = ExpressionWithValue.ToValuedCode(() => TheGenericMethod <int>(2)); Assert.AreEqual("TheGenericMethod<Int32>(2) = Return value is 4", actual); }
public void TheMethod() { var actual = ExpressionWithValue.ToValuedCode(() => TheMethod(1, "2")); Assert.AreEqual("TheMethod(1, \"2\") = TheMethod 1 2", actual); }
public void ThePropertyAccess() { var actual = ExpressionWithValue.ToValuedCode(() => TheProperty); Assert.AreEqual("TheProperty = TheValue", actual); }