Fix calling constructors with ref and in parameters (#1728)
This commit is contained in:
@@ -47,6 +47,33 @@ namespace Newtonsoft.Json.Tests.Utilities
|
||||
[TestFixture]
|
||||
public class ExpressionReflectionDelegateFactoryTests : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void ConstructorWithInString()
|
||||
{
|
||||
ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(InTestClass)).Single(c => c.GetParameters().Count() == 1);
|
||||
|
||||
var creator = ExpressionReflectionDelegateFactory.Instance.CreateParameterizedConstructor(constructor);
|
||||
|
||||
object[] args = new object[] { "Value" };
|
||||
InTestClass o = (InTestClass)creator(args);
|
||||
Assert.IsNotNull(o);
|
||||
Assert.AreEqual("Value", o.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConstructorWithInStringAndBool()
|
||||
{
|
||||
ConstructorInfo constructor = TestReflectionUtils.GetConstructors(typeof(InTestClass)).Single(c => c.GetParameters().Count() == 2);
|
||||
|
||||
var creator = ExpressionReflectionDelegateFactory.Instance.CreateParameterizedConstructor(constructor);
|
||||
|
||||
object[] args = new object[] { "Value", true };
|
||||
InTestClass o = (InTestClass)creator(args);
|
||||
Assert.IsNotNull(o);
|
||||
Assert.AreEqual("Value", o.Value);
|
||||
Assert.AreEqual(true, o.B1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConstructorWithRefString()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user