public void BeginScopeDoesNotThrowIfAlreadyDisposed() { Obj.Dispose(); TestDelegate action = () => Obj.BeginScope(); Assert.That(action, Throws.Nothing); }
public void DisposeReleasesComponentResolvedFromGetServices() { var invokeGetServicesCounter = 0; var myComponents = new List <object>(); var scope = Obj.BeginScope(); container.Setup(x => x.ResolveAll(typeof(IMyService))) .Callback(() => myComponents.AddRange(Enumerable.Range(0, ++invokeGetServicesCounter).Select(n => new Mock <IMyService>().Object))) .Returns((Type a) => myComponents.AsEnumerable().Reverse().Take(invokeGetServicesCounter).Reverse().ToArray()); kernel.Setup(x => x.HasComponent(typeof(IMyService))) .Returns(true); var results = Enumerable.Range(1, Rand.Next(1, 10)) .SelectMany(n => scope.GetServices(typeof(IMyService))) .ToArray(); Assume.That(myComponents, Is.EquivalentTo(results)); myComponents.ForEach(component => container.Setup(x => x.Release(component)) .Verifiable()); scope.Dispose(); container.Verify(); }
public void BeginScopeThrowsIfScopeAlreadyDisposed() { var scope = (WindsorDependencyResolver)Obj.BeginScope(); scope.Dispose(); TestDelegate action = () => scope.BeginScope(); Assert.That(action, Throws.InstanceOf <ObjectDisposedException>()); }
public void GetServicesThrowsIfScopeAlreadyDisposed() { var scope = Obj.BeginScope(); scope.Dispose(); TestDelegate action = () => scope.GetServices(typeof(IMyService)); Assert.That(action, Throws.InstanceOf <ObjectDisposedException>()); }
public void BeginScopeDisposeScopeDoesNotDisposeContainer() { var scope = Obj.BeginScope(); scope.Dispose(); container.Verify(x => x.Dispose(), Times.Never()); }