Esempio n. 1
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);
        }
Esempio n. 2
0
        public void CallGenericMethod(int iterationCount)
        {
            DateTime now = DateTime.Now;

            for (int i = 0; i < iterationCount; i++)
            {
                _target.FastInvoke("TwoGenericArguments", "Name", now);
            }
        }
Esempio n. 3
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));
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
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);
		}
Esempio n. 8
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));
		}
Esempio n. 9
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));
		}
Esempio n. 10
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));
        }
Esempio n. 11
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));
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
		}
Esempio n. 15
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);
		}
Esempio n. 16
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);
	    }
Esempio n. 17
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));
	    }