public void TestAfterResolve() { var eventCalled = false; IReflectionCache cache = new ReflectionCache(); IBinder binder = new Binder(); IInjector injector = new Injector(cache, binder, ResolutionMode.ALWAYS_RESOLVE); IMockInterface resolvedInstance = null; injector.afterResolve += delegate(IInjector source, Type type, InjectionMember member, object parentInstance, object identifier, ref object resolutionInstance) { Assert.AreEqual(injector, source); Assert.AreEqual(typeof(IMockInterface), type); Assert.AreEqual(InjectionMember.None, member); Assert.IsNull(parentInstance); Assert.IsNull(identifier); Assert.IsNotNull(resolutionInstance); resolvedInstance = (IMockInterface)resolutionInstance; eventCalled = true; return(false); }; binder.Bind <IMockInterface>().To <MockIClass>(); var instance = injector.Resolve <IMockInterface>(); Assert.IsTrue(eventCalled); Assert.AreEqual(typeof(MockIClass), instance.GetType()); Assert.AreEqual(resolvedInstance, instance); }
public void CreateMonoServiceAndResolveIt() { ServiceLocatorManager.Register <IMockInterface>(ServiceLocatorManager.AsMono <MonoMockServiceFeature>()); IMockInterface service = ServiceLocatorManager.Resolve <IMockInterface>(); Assert.IsInstanceOf(typeof(MonoMockServiceFeature), service); }
public void CreateNonMonoServiceAndResolveIt() { ServiceLocatorManager.Register <IMockInterface>(new MockServiceOldFeature()); IMockInterface oldService = ServiceLocatorManager.Resolve <IMockInterface>(); Assert.IsInstanceOf(typeof(MockServiceOldFeature), oldService); }
public void TestInvalidValue() { IMockInterface mockedInterface = mockRepository.StrictMock <IMockInterface>(); Expect.Call(mockedInterface.InvalidValue).Return(100UL); mockRepository.ReplayAll(); Assert.Equal(100UL, mockedInterface.InvalidValue); }
public void CreateNonMonoServiceDeleteItAndResolveIt() { Debug.logger.logEnabled = false; ServiceLocatorManager.Register <IMockInterface>(new MockServiceOldFeature()); ServiceLocatorManager.Reset(); IMockInterface service = ServiceLocatorManager.Resolve <IMockInterface>(); Assert.IsNull(service); }
public void CreateMonoServiceResetItAndResolveIt() { Debug.unityLogger.logEnabled = false; serviceLocatorManager.Register <IMockInterface>(ServiceLocatorManager.AsMono <MonoMockServiceFeature>()); serviceLocatorManager.Reset(); IMockInterface service = serviceLocatorManager.Resolve <IMockInterface>(); var obj = Object.FindObjectOfType <MonoMockServiceFeature>(); Assert.IsNull(obj); }
public IEnumerator CreateMonoServiceResetItAndResolveIt() { Debug.logger.logEnabled = false; ServiceLocatorManager.Register <IMockInterface>(ServiceLocatorManager.AsMono <MonoMockServiceFeature>()); ServiceLocatorManager.Reset(); IMockInterface service = ServiceLocatorManager.Resolve <IMockInterface>(); Assert.IsNull(service); yield return(new WaitForEndOfFrame()); var obj = Object.FindObjectOfType <MonoMockServiceFeature>(); Assert.IsNull(obj); }
public MockClassSimpleConstructInject([Inject(TestIdentifier.MockClass3)] IMockInterface mock) { this.mock = mock; }
public FieldProblem_Derek() { mockedInterface = MockRepository.Mock <IMockInterface>(); mockedInterface.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); }
protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2) { this.propertyMock1 = mock1; this.propertyMock2 = mock2; }
public FieldProblem_Derek() { mockedInterface = MockRepository.Mock <IMockInterface>(); }
public FieldProblem_Derek() { mockedInterface = MockRepository.Mock<IMockInterface>(); }