コード例 #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);
        }
コード例 #2
0
        public void CreateMonoServiceAndResolveIt()
        {
            ServiceLocatorManager.Register <IMockInterface>(ServiceLocatorManager.AsMono <MonoMockServiceFeature>());

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

            Assert.IsInstanceOf(typeof(MonoMockServiceFeature), service);
        }
コード例 #3
0
        public void CreateNonMonoServiceAndResolveIt()
        {
            ServiceLocatorManager.Register <IMockInterface>(new MockServiceOldFeature());

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

            Assert.IsInstanceOf(typeof(MockServiceOldFeature), oldService);
        }
コード例 #4
0
        public void TestInvalidValue()
        {
            IMockInterface mockedInterface = mockRepository.StrictMock <IMockInterface>();

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

            ServiceLocatorManager.Reset();

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

            Assert.IsNull(service);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #8
0
ファイル: TestObjects.cs プロジェクト: cgarciae/adic
 public MockClassSimpleConstructInject([Inject(TestIdentifier.MockClass3)] IMockInterface mock)
 {
     this.mock = mock;
 }
コード例 #9
0
 public FieldProblem_Derek()
 {
     mockedInterface = MockRepository.Mock <IMockInterface>();
     mockedInterface.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);
 }
コード例 #10
0
ファイル: TestObjects.cs プロジェクト: NotYours180/adic
 public MockClassSimpleConstructInject([Inject(TestIdentifier.MockClass3)] IMockInterface mock)
 {
     this.mock = mock;
 }
コード例 #11
0
ファイル: TestObjects.cs プロジェクト: NotYours180/adic
 protected void PostConstructor([Inject(TestIdentifier.MockClass3)] IMockInterface mock1, MockClassToDepend mock2)
 {
     this.propertyMock1 = mock1;
     this.propertyMock2 = mock2;
 }
コード例 #12
0
 public FieldProblem_Derek()
 {
     mockedInterface = MockRepository.Mock <IMockInterface>();
 }
コード例 #13
0
		public FieldProblem_Derek()
		{
            mockedInterface = MockRepository.Mock<IMockInterface>();
		}