Exemple #1
0
        public ReflectionMethodRunner()
        {
            _target = new ClassWithGenericMethods();

            _method = typeof(ClassWithGenericMethods)
                      .GetMethod("TwoGenericArguments");
        }
		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));
		}
Exemple #4
0
        public KnownReflectionMethodRunner()
        {
            _target = new ClassWithGenericMethods();

            _method = typeof(ClassWithGenericMethods)
                      .GetMethod("TwoGenericArguments")
                      .MakeGenericMethod(typeof(string), typeof(DateTime));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
        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);
            }
        }
Exemple #9
0
		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);
		}
Exemple #10
0
		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));
		}
Exemple #11
0
		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));
		}
Exemple #12
0
        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));
        }
Exemple #13
0
        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));
        }
Exemple #14
0
        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);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
		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);
		}
Exemple #17
0
        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);
        }
Exemple #18
0
        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);
            }
        }
Exemple #19
0
        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);
            }
        }
Exemple #20
0
		public DirectMethodRunner()
		{
			_target = new ClassWithGenericMethods();
		}
Exemple #21
0
 public FastInvokerMethodRunner()
 {
     _target = new ClassWithGenericMethods();
 }
Exemple #22
0
	    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);
	    }
Exemple #23
0
	    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));
	    }
Exemple #24
0
 public DirectMethodRunner()
 {
     _target = new ClassWithGenericMethods();
 }
		public FastInvokerMethodRunner()
		{
			_target = new ClassWithGenericMethods();
		}
Exemple #26
0
 public KnownFastInvokerMethodRunner()
 {
     _target  = new ClassWithGenericMethods();
     _invoker = FastInvoker <ClassWithGenericMethods> .Current.GetInvoker("TwoGenericArguments",
                                                                          new object[] { "Name", DateTime.Now });
 }
Exemple #27
0
		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);
		}