Exemplo n.º 1
0
        public void TestBindNotAssignableKeyTypeToInstance()
        {
            var binder = new Binder();

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

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

            var instance = new MockClassToDepend();

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

            var instance = new MockClassToDepend();

            binder.Bind <MockClassToDepend>().To(typeof(MockClassVerySimple), instance);
        }
Exemplo n.º 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);
            });
        }
Exemplo n.º 6
0
        /// <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);
            }
        }
Exemplo n.º 7
0
        public void TestBindNotAssignableKeyTypeToInstance()
        {
            var binder = new Binder();

            var instance = new MockClassToDepend();

            Assert.Throws(typeof(BindingException), delegate {
                binder.Bind <IMockInterface>().To <MockClassToDepend>(instance);
            });
        }
Exemplo n.º 8
0
        /// <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);
            }
        }
Exemplo n.º 9
0
 public MockIClassWithoutAttributes(MockClassToDepend dependency)
 {
     this.dependency = dependency;
 }
Exemplo n.º 10
0
 public MockIClassWithoutAttributes(MockClassToDepend dependency)
 {
     this.dependency = dependency;
 }
Exemplo n.º 11
0
 public void Method(MockClassToDepend field1, MockClassToDepend field2)
 {
     this.fieldFromMethod1 = field1;
     this.fieldFromMethod2 = field2;
 }
Exemplo n.º 12
0
 public MockClassWithDependencies(MockClassToDepend dependency)
 {
     this.dependencyFromConstructor = dependency;
 }
Exemplo n.º 13
0
 public MockIClassWithAttributes(MockClassToDepend dependency)
 {
 }
Exemplo n.º 14
0
 protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2)
 {
     this.propertyMock1 = mock1;
     this.propertyMock2 = mock2;
 }
Exemplo n.º 15
0
 public MockClassWithDependencies(MockClassToDepend dependency)
 {
     this.dependencyFromConstructor = dependency;
 }
Exemplo n.º 16
0
 public MockClassInjectAll(MockClassToDepend field1, MockClassToDepend field2)
 {
     this.fieldFromConstructor1 = field1;
     this.fieldFromConstructor2 = field2;
 }
Exemplo n.º 17
0
		/// <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);
			}
		}
Exemplo n.º 18
0
		/// <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);
			}
		}
Exemplo n.º 19
0
 public MockIClassWithAttributes(MockClassToDepend dependency)
 {
 }
Exemplo n.º 20
0
 protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2)
 {
     this.propertyMock1 = mock1;
     this.propertyMock2 = mock2;
 }