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); }
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); } }
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); } }
public MockIClassWithoutAttributes(MockClassToDepend dependency) { this.dependency = dependency; }
public void Method(MockClassToDepend field1, MockClassToDepend field2) { this.fieldFromMethod1 = field1; this.fieldFromMethod2 = field2; }
public MockClassWithDependencies(MockClassToDepend dependency) { this.dependencyFromConstructor = dependency; }
public MockIClassWithAttributes(MockClassToDepend dependency) { }
protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2) { this.propertyMock1 = mock1; this.propertyMock2 = mock2; }
public MockClassInjectAll(MockClassToDepend field1, MockClassToDepend field2) { this.fieldFromConstructor1 = field1; this.fieldFromConstructor2 = field2; }
/// <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); } }