Esempio n. 1
0
        public void Init()
        {
            _fakeService        = new FakeService();
            _anotherFakeService = new AnotherFakeService();

            _injector = new Injector();
            _injector.Bind <IFakeService>(_fakeService);
            _injector.Bind <IAnotherFakeService>(_anotherFakeService);
        }
Esempio n. 2
0
        public void ThrowAfterUnbind()
        {
            var fakeService = new FakeService();

            var injector = new Injector();
            var receiver = new SingleFieldInjectReceiver();

            injector.Bind <IFakeService>(fakeService);
            injector.Inject(receiver);

            Assert.AreSame(fakeService, receiver.PrivateFakeService);

            injector.Unbind <IFakeService>();
            Assert.Throws <DependencyInjectionException>(
                () => { injector.Inject(receiver); }
                );
        }
Esempio n. 3
0
        public void SetOptionalToNullAfterUnbind()
        {
            var fakeService = new FakeService();

            var injector = new Injector();
            var receiver = new OptionalFieldInjectReceiver();

            injector.Bind <IFakeService>(fakeService);
            injector.Inject(receiver);

            Assert.AreSame(fakeService, receiver.OptionalPrivateFakeService);

            injector.Unbind <IFakeService>();
            injector.Inject(receiver);

            Assert.AreSame(null, receiver.OptionalPrivateFakeService);
        }
Esempio n. 4
0
 public void Init()
 {
     _fakeService = new FakeService();
     _injector    = new UnityInjector();
     _injector.Bind <IFakeService>(_fakeService);
 }