public void Transform_ThrowsArgumentException_IfNoConstructorWithEquavilentParameterListIsFound() { // Creating the expression "Fixture.CreateTestClass(5, 5)" Expression input = Expression.Call(FixtureCreateTestClass3, Expression.Constant(5), Expression.Constant(5)); // Validating that ConstructorCallAttribute fails on non-existent delegate ConstructorCallAttribute attribute = new ConstructorCallAttribute(); Assert.ThrowsException <ArgumentException>(() => attribute.Transform(input)); }
public void Transform_ReplacesMethodCallExpressionWithArgumentsWithNewExpression() { // Creating the expression "Fixture.CreateTestClass(5)" Expression input = Expression.Call(FixtureCreateTestClass2, Expression.Constant(5)); // Validating that ConstructorCallAttribute creates expression calling Fixture(5) Expression output = new ConstructorCallAttribute().Transform(input); Func <Fixture> createFixture = Expression.Lambda <Func <Fixture> >(output).Compile(); Fixture fixture = createFixture(); Assert.AreEqual(fixture.Value, 5); }