Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void CreateMonoServiceAndResolveIt()
        {
            ServiceLocatorManager.Register <IMockInterface>(ServiceLocatorManager.AsMono <MonoMockServiceFeature>());

            IMockInterface service = ServiceLocatorManager.Resolve <IMockInterface>();

            Assert.IsInstanceOf(typeof(MonoMockServiceFeature), service);
        }
Esempio n. 3
0
        public void CreateNonMonoServiceAndResolveIt()
        {
            ServiceLocatorManager.Register <IMockInterface>(new MockServiceOldFeature());

            IMockInterface oldService = ServiceLocatorManager.Resolve <IMockInterface>();

            Assert.IsInstanceOf(typeof(MockServiceOldFeature), oldService);
        }
Esempio n. 4
0
        public void TestInvalidValue()
        {
            IMockInterface mockedInterface = mockRepository.StrictMock <IMockInterface>();

            Expect.Call(mockedInterface.InvalidValue).Return(100UL);
            mockRepository.ReplayAll();
            Assert.Equal(100UL, mockedInterface.InvalidValue);
        }
Esempio n. 5
0
        public void CreateNonMonoServiceDeleteItAndResolveIt()
        {
            Debug.logger.logEnabled = false;
            ServiceLocatorManager.Register <IMockInterface>(new MockServiceOldFeature());

            ServiceLocatorManager.Reset();

            IMockInterface service = ServiceLocatorManager.Resolve <IMockInterface>();

            Assert.IsNull(service);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public MockClassSimpleConstructInject([Inject(TestIdentifier.MockClass3)] IMockInterface mock)
 {
     this.mock = mock;
 }
 public FieldProblem_Derek()
 {
     mockedInterface = MockRepository.Mock <IMockInterface>();
     mockedInterface.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);
 }
Esempio n. 10
0
 public MockClassSimpleConstructInject([Inject(TestIdentifier.MockClass3)] IMockInterface mock)
 {
     this.mock = mock;
 }
Esempio n. 11
0
 protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2)
 {
     this.propertyMock1 = mock1;
     this.propertyMock2 = mock2;
 }
Esempio n. 12
0
 public FieldProblem_Derek()
 {
     mockedInterface = MockRepository.Mock <IMockInterface>();
 }
		public FieldProblem_Derek()
		{
            mockedInterface = MockRepository.Mock<IMockInterface>();
		}