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

            _injector = new Injector();
            _injector.Bind <IFakeService>(_fakeService);
            _injector.Bind <IAnotherFakeService>(_anotherFakeService);
        }
Exemplo 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); }
                );
        }
Exemplo 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);
        }
Exemplo n.º 4
0
 public void Init()
 {
     _fakeService = new FakeService();
     _injector    = new UnityInjector();
     _injector.Bind <IFakeService>(_fakeService);
 }