public ReflectionMethodRunner() { _target = new ClassWithGenericMethods(); _method = typeof(ClassWithGenericMethods) .GetMethod("TwoGenericArguments"); }
public KnownReflectionMethodRunner() { _target = new ClassWithGenericMethods(); _method = typeof(ClassWithGenericMethods) .GetMethod("TwoGenericArguments") .MakeGenericMethod(typeof(string), typeof(DateTime)); }
public void The_generic_method_should_use_the_most_specific_type() { var target = new ClassWithGenericMethods(); var argTypes = new Type[] { typeof(DateTime) }; target.FastInvoke(argTypes, x => x.OneGenericArgumentNoParameters <int>()); target.OneGenericArgumentNoParametersCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(DateTime)); }
public void The_generic_method_should_be_invoked() { var target = new ClassWithGenericMethods(); object name = "Name"; target.FastInvoke(x => x.OneGenericArgument(0), name); target.OneGenericArgumentCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(string)); target.FirstArgumentValue.ShouldEqual(name); }
public void FirstTestName() { var target = new ClassWithGenericMethods(); object name = "Name"; object when = DateTime.Now; for (int i = 0; i < _iterations; i++) { target.FastInvoke(x => x.TwoGenericArguments(0, 0), name, when); } }
public void The_generic_method_should_be_invoked() { var target = new ClassWithGenericMethods(); object name = "Name"; target.FastInvoke(x => x.OneGenericArgument(0), name); target.OneGenericArgumentCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof (string)); target.FirstArgumentValue.ShouldEqual(name); }
public void Invoking_by_name_works() { var target = new ClassWithGenericMethods(); object value = new ClassWithGuidConstraint(Guid.NewGuid()); target.FastInvoke("TwoGenericArgumentsOneParameter", value); target.TwoGenericArgumentsOneParameterCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(ClassWithGuidConstraint)); target.FirstArgumentValue.ShouldEqual(value); target.SecondArgumentType.ShouldEqual(typeof (Guid)); }
public void The_single_argument_two_type_method_should_be_invoked() { var target = new ClassWithGenericMethods(); object value = new ClassWithGuidConstraint(Guid.NewGuid()); target.FastInvoke(x => x.TwoGenericArgumentsOneParameter<ClassWithStringConstraint, string>(null), value); target.TwoGenericArgumentsOneParameterCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(ClassWithGuidConstraint)); target.FirstArgumentValue.ShouldEqual(value); target.SecondArgumentType.ShouldEqual(typeof (Guid)); }
public void Invoking_by_name_works() { var target = new ClassWithGenericMethods(); object value = new ClassWithGuidConstraint(Guid.NewGuid()); target.FastInvoke("TwoGenericArgumentsOneParameter", value); target.TwoGenericArgumentsOneParameterCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(ClassWithGuidConstraint)); target.FirstArgumentValue.ShouldEqual(value); target.SecondArgumentType.ShouldEqual(typeof(Guid)); }
public void The_single_argument_two_type_method_should_be_invoked() { var target = new ClassWithGenericMethods(); object value = new ClassWithGuidConstraint(Guid.NewGuid()); target.FastInvoke(x => x.TwoGenericArgumentsOneParameter <ClassWithStringConstraint, string>(null), value); target.TwoGenericArgumentsOneParameterCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(ClassWithGuidConstraint)); target.FirstArgumentValue.ShouldEqual(value); target.SecondArgumentType.ShouldEqual(typeof(Guid)); }
public void The_generic_method_should_be_invoked_and_not_cached_improperly() { var target = new ClassWithGenericMethods(); object name = "Name"; const int value = 47; target.FastInvoke(x => x.OneGenericArgument(0), name); target.FastInvoke(x => x.OneGenericArgument(0), value); target.OneGenericArgumentCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(int)); target.FirstArgumentValue.ShouldEqual(value); }
public void The_generic_method_should_use_the_most_specific_type_but_not_the_argument_type() { var target = new ClassWithGenericMethods(); var argTypes = new[] { typeof(double) }; object name = "Name"; target.FastInvoke(argTypes, x => x.OneGenericArgumentOnUnrelatedParameter <int>(null), name); target.OneGenericArgumentOnUnrelatedParameterCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(double)); target.SecondArgumentType.ShouldEqual(typeof(string)); target.SecondArgumentValue.ShouldEqual(name); }
public void The_two_argument_generic_method_should_be_invoked() { var target = new ClassWithGenericMethods(); object name = "Name"; object when = DateTime.Now; target.FastInvoke(x => x.TwoGenericArguments(0, 0), name, when); target.TwoGenericArgumentsCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof (string)); target.FirstArgumentValue.ShouldEqual(name); target.SecondArgumentType.ShouldEqual(typeof (DateTime)); target.SecondArgumentValue.ShouldEqual(when); }
public void The_two_argument_generic_method_should_be_invoked() { var target = new ClassWithGenericMethods(); object name = "Name"; object when = DateTime.Now; target.FastInvoke(x => x.TwoGenericArguments(0, 0), name, when); target.TwoGenericArgumentsCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(string)); target.FirstArgumentValue.ShouldEqual(name); target.SecondArgumentType.ShouldEqual(typeof(DateTime)); target.SecondArgumentValue.ShouldEqual(when); }
public void Using_regular_old_Invoke() { var target = new ClassWithGenericMethods(); object name = "Name"; object when = DateTime.Now; var args = new object[] {name, when}; MethodInfo method = typeof (ClassWithGenericMethods) .GetMethod("TwoGenericArguments"); //.MakeGenericMethod(typeof (string), typeof (DateTime)); for (int i = 0; i < _iterations; i++) { method.MakeGenericMethod(typeof (string), typeof (DateTime)).Invoke(target, args); } }
public void Using_regular_old_Invoke() { var target = new ClassWithGenericMethods(); object name = "Name"; object when = DateTime.Now; var args = new object[] { name, when }; MethodInfo method = typeof(ClassWithGenericMethods) .GetMethod("TwoGenericArguments"); //.MakeGenericMethod(typeof (string), typeof (DateTime)); for (int i = 0; i < _iterations; i++) { method.MakeGenericMethod(typeof(string), typeof(DateTime)).Invoke(target, args); } }
public DirectMethodRunner() { _target = new ClassWithGenericMethods(); }
public FastInvokerMethodRunner() { _target = new ClassWithGenericMethods(); }
public void The_generic_method_should_use_the_most_specific_type_but_not_the_argument_type() { var target = new ClassWithGenericMethods(); var argTypes = new[]{typeof(double)}; object name = "Name"; target.FastInvoke(argTypes, x => x.OneGenericArgumentOnUnrelatedParameter<int>(null), name); target.OneGenericArgumentOnUnrelatedParameterCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof(double)); target.SecondArgumentType.ShouldEqual(typeof(string)); target.SecondArgumentValue.ShouldEqual(name); }
public void The_generic_method_should_use_the_most_specific_type() { var target = new ClassWithGenericMethods(); var argTypes = new Type[]{typeof(DateTime)}; target.FastInvoke(argTypes, x => x.OneGenericArgumentNoParameters<int>()); target.OneGenericArgumentNoParametersCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof (DateTime)); }
public KnownFastInvokerMethodRunner() { _target = new ClassWithGenericMethods(); _invoker = FastInvoker <ClassWithGenericMethods> .Current.GetInvoker("TwoGenericArguments", new object[] { "Name", DateTime.Now }); }
public void The_generic_method_should_be_invoked_and_not_cached_improperly() { var target = new ClassWithGenericMethods(); object name = "Name"; const int value = 47; target.FastInvoke(x => x.OneGenericArgument(0), name); target.FastInvoke(x => x.OneGenericArgument(0), value); target.OneGenericArgumentCalled.ShouldBeTrue(); target.FirstArgumentType.ShouldEqual(typeof (int)); target.FirstArgumentValue.ShouldEqual(value); }