public void TestBindNotAssignableKeyTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();
            binder.Bind<IMockInterface>().To<MockClassToDepend>(instance);
        }
        public void TestBindNotAssignableInstanceTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();
            binder.Bind<MockClassToDepend>().To(typeof(MockClassVerySimple), instance);
        }
        public void TestBindNotAssignableKeyTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();

            binder.Bind <IMockInterface>().To <MockClassToDepend>(instance);
        }
        public void TestBindNotAssignableInstanceTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();

            binder.Bind <MockClassToDepend>().To(typeof(MockClassVerySimple), instance);
        }
Exemple #5
0
        public void TestBindNotAssignableInstanceTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();

            Assert.Throws(typeof(BindingException), delegate {
                binder.Bind <MockClassToDepend>().To(typeof(MockClassVerySimple), instance);
            });
        }
        /// <summary>
        /// Executes construct directly one million times.
        /// </summary>
        public void ExecuteConstructWithParamsDirectly()
        {
            MockIClassWithoutAttributes instance = null;
            var dependency = new MockClassToDepend();

            for (int i = 0; i < 1000000; i++)
            {
                instance = new MockIClassWithoutAttributes(dependency);
            }
        }
Exemple #7
0
        public void TestBindNotAssignableKeyTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();

            Assert.Throws(typeof(BindingException), delegate {
                binder.Bind <IMockInterface>().To <MockClassToDepend>(instance);
            });
        }
        /// <summary>
        /// Executes construct by reflection one million times.
        /// </summary>
        public void ExecuteConstructWithParamsByReflection()
        {
            MockIClassWithoutAttributes instance = null;
            var constructorInfo = typeof(MockIClassWithoutAttributes).GetConstructors(
                BindingFlags.FlattenHierarchy |
                BindingFlags.Public |
                BindingFlags.Instance |
                BindingFlags.InvokeMethod)[1];
            var dependency = new MockClassToDepend();

            object[] parameters = new object[1] {
                dependency
            };

            for (int i = 0; i < 1000000; i++)
            {
                instance = (MockIClassWithoutAttributes)constructorInfo.Invoke(parameters);
            }
        }
Exemple #9
0
 public MockIClassWithoutAttributes(MockClassToDepend dependency)
 {
     this.dependency = dependency;
 }
Exemple #10
0
 public MockIClassWithoutAttributes(MockClassToDepend dependency)
 {
     this.dependency = dependency;
 }
Exemple #11
0
 public void Method(MockClassToDepend field1, MockClassToDepend field2)
 {
     this.fieldFromMethod1 = field1;
     this.fieldFromMethod2 = field2;
 }
Exemple #12
0
 public MockClassWithDependencies(MockClassToDepend dependency)
 {
     this.dependencyFromConstructor = dependency;
 }
Exemple #13
0
 public MockIClassWithAttributes(MockClassToDepend dependency)
 {
 }
Exemple #14
0
 protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2)
 {
     this.propertyMock1 = mock1;
     this.propertyMock2 = mock2;
 }
Exemple #15
0
 public MockClassWithDependencies(MockClassToDepend dependency)
 {
     this.dependencyFromConstructor = dependency;
 }
Exemple #16
0
 public MockClassInjectAll(MockClassToDepend field1, MockClassToDepend field2)
 {
     this.fieldFromConstructor1 = field1;
     this.fieldFromConstructor2 = field2;
 }
		/// <summary>
		/// Executes construct directly one million times.
		/// </summary>
		public void ExecuteConstructWithParamsDirectly() {
			MockIClassWithoutAttributes instance = null;
			var dependency = new MockClassToDepend();
			for (int i = 0; i < 1000000; i++) {
				instance = new MockIClassWithoutAttributes(dependency);
			}
		}
		/// <summary>
		/// Executes construct by IL one million times.
		/// </summary>
		public void ExecuteConstructWithParamsByIL() {
			MockIClassWithoutAttributes instance = null;
			var constructorInfo = typeof(MockIClassWithoutAttributes).GetConstructors(
				BindingFlags.FlattenHierarchy | 
				BindingFlags.Public |
				BindingFlags.Instance |
				BindingFlags.InvokeMethod)[1];
			var dependency = new MockClassToDepend();
			object[] parameters = new object[1] { dependency };

			var constructor = ReflectionUtils.CreateConstructorWithParams<MockIClassWithoutAttributes>(constructorInfo);
			for (int i = 0; i < 1000000; i++) {
				instance = constructor(parameters);
			}
		}
Exemple #19
0
 public MockIClassWithAttributes(MockClassToDepend dependency)
 {
 }
Exemple #20
0
 protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2)
 {
     this.propertyMock1 = mock1;
     this.propertyMock2 = mock2;
 }