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