public void GivenSingletonConfiguration_WhenCallingBeginScope_EachTimeShouldReturnTheSame() { //arrange var depResolver = new NinjectResolver(new FakeNinjectModule()); //act var instance1 = depResolver.BeginScope().GetService(typeof(IFakeService)); var instance2 = depResolver.BeginScope().GetService(typeof(IFakeService)); Assert.That(instance1, Is.EqualTo(instance2)); }
public void GivenScopedConfiguration_WhenCallingBeginScope_EachTimeShouldReturnNewInstance() { //arrange var depResolver = new NinjectResolver(); depResolver.AddRequestScopedModules(new FakeNinjectModule()); //act var instance1 = depResolver.BeginScope().GetService(typeof(IFakeService)); var instance2 = depResolver.BeginScope().GetService(typeof(IFakeService)); Assert.That(instance1, Is.Not.EqualTo(instance2)); }
public void CanResolve_RequestScopedDependency() { //arrange var depResolver = new NinjectResolver(); depResolver.AddRequestScopedModules(new FakeNinjectModule()); //assert Assert.That(depResolver.BeginScope().GetService(typeof(IFakeService)), Is.TypeOf <FakeService>()); }