public void ScopesReturnSelfAsResolutionRoot() { IResolutionRoot customScope = new CustomScope(_mainKernel); var resRoot = customScope.Get <IResolutionRoot>(); Assert.That(resRoot, Is.SameAs(customScope)); }
public void ScopeServiceDifferentFromDefaultService() { IResolutionRoot customScope = new CustomScope(_mainKernel); var a = _mainKernel.Get <IService>(); var b = customScope.Get <IService>(); Assert.That(a, Is.Not.SameAs(b)); }
public void SameScopeSameService() { IResolutionRoot customScope = new CustomScope(_mainKernel); var a = customScope.Get <IService>(); var b = customScope.Get <IService>(); Assert.That(a, Is.SameAs(b)); }
public void InjectedAndResolvedChildrenGetSameService() { IResolutionRoot customScope = new CustomScope(_mainKernel); var a = customScope.Get <ComplexClass>(); Assert.That(a.InjectedServiceUser.Service, Is.SameAs(a.ResolvedServiceUser.Service)); }
public void DifferentExplicitScopes() { IResolutionRoot customScope1 = new CustomScope(_mainKernel); IResolutionRoot customScope2 = new CustomScope(_mainKernel); var a = customScope1.Get<IService>(); var b = customScope2.Get<IService>(); Assert.That(a, Is.Not.SameAs(b)); }
public void DifferentExplicitScopes() { IResolutionRoot customScope1 = new CustomScope(_mainKernel); IResolutionRoot customScope2 = new CustomScope(_mainKernel); var a = customScope1.Get <IService>(); var b = customScope2.Get <IService>(); Assert.That(a, Is.Not.SameAs(b)); }
public void CustomScopeObjectsGetGarbageCollectedWhenCustomScopeGetsGarbageCollected() { CustomScope customScope = new CustomScope(_mainKernel); var weakRef = new WeakReference(customScope.Get<IService>()); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); Assert.That(weakRef.IsAlive, Is.True); customScope = null; GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); Thread.Sleep(100); // required to let Ninject's cache pruning thread run. GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); Assert.That(customScope, Is.Null); Assert.That(weakRef.IsAlive, Is.False); }
public void ChildrenGetSameServiceButDifferFromResultFromOtherKernels() { var a = _mainKernel.Get<ComplexClass>(); Assert.That(a.InjectedServiceUser.Service, Is.SameAs(a.ResolvedServiceUser.Service)); IResolutionRoot customScope = new CustomScope(_mainKernel); var b = customScope.Get<ComplexClass>(); Assert.That(b.InjectedServiceUser.Service, Is.SameAs(b.ResolvedServiceUser.Service)); Assert.That(a.ResolvedServiceUser.Service, Is.Not.SameAs(b.ResolvedServiceUser.Service)); Assert.That(a.InjectedServiceUser.Service, Is.Not.SameAs(b.InjectedServiceUser.Service)); }
public void CustomScopeObjectsGetGarbageCollectedWhenCustomScopeGetsGarbageCollected() { CustomScope customScope = new CustomScope(_mainKernel); var weakRef = new WeakReference(customScope.Get <IService>()); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); Assert.That(weakRef.IsAlive, Is.True); customScope = null; GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); Thread.Sleep(100); // required to let Ninject's cache pruning thread run. GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); Assert.That(customScope, Is.Null); Assert.That(weakRef.IsAlive, Is.False); }
public void ChildrenGetSameServiceButDifferFromResultFromOtherKernels() { var a = _mainKernel.Get <ComplexClass>(); Assert.That(a.InjectedServiceUser.Service, Is.SameAs(a.ResolvedServiceUser.Service)); IResolutionRoot customScope = new CustomScope(_mainKernel); var b = customScope.Get <ComplexClass>(); Assert.That(b.InjectedServiceUser.Service, Is.SameAs(b.ResolvedServiceUser.Service)); Assert.That(a.ResolvedServiceUser.Service, Is.Not.SameAs(b.ResolvedServiceUser.Service)); Assert.That(a.InjectedServiceUser.Service, Is.Not.SameAs(b.InjectedServiceUser.Service)); }
public void InjectedAndResolvedChildrenGetSameService() { IResolutionRoot customScope = new CustomScope(_mainKernel); var a = customScope.Get<ComplexClass>(); Assert.That(a.InjectedServiceUser.Service, Is.SameAs(a.ResolvedServiceUser.Service)); }
public void ScopesReturnSelfAsResolutionRoot() { IResolutionRoot customScope = new CustomScope(_mainKernel); var resRoot = customScope.Get<IResolutionRoot>(); Assert.That(resRoot, Is.SameAs(customScope)); }
public void ScopeServiceDifferentFromDefaultService() { IResolutionRoot customScope = new CustomScope(_mainKernel); var a = _mainKernel.Get<IService>(); var b = customScope.Get<IService>(); Assert.That(a, Is.Not.SameAs(b)); }
public void SameScopeSameService() { IResolutionRoot customScope = new CustomScope(_mainKernel); var a = customScope.Get<IService>(); var b = customScope.Get<IService>(); Assert.That(a, Is.SameAs(b)); }