public void TryResolve_NotRegisteredServiceWithMultipuleArguments_DontThrowsRegistrationExceptionAndReturnsNull() { var container = new NCopContainer(registry => { }); var instance = container.TryResolve <string, int, IFoo>("NCop", 9); Assert.IsNull(instance); }
public void TryResolve_NotRegisteredService_DontThrowsRegistrationExceptionAndReturnsNull() { var container = new NCopContainer(registry => { }); var instance = container.TryResolve <IFoo>(); Assert.IsNull(instance); }
public void DisposeOfContainer_OfDisposableNamedObjectWithAnArgumentWhichIsOwnedExternally_ReturnsTheNamedInstanceWithNotDispsoedIndication() { var container = new NCopContainer(registry => { registry.Register <IFoo, string>((c, name) => new Foo(name)) .Named("NCop") .OwnedExternally(); }); var instance = container.TryResolve <string, IFoo>("NCop", "NCop") as Foo; container.Dispose(); Assert.IsNotNull(instance); Assert.IsTrue(instance.Name.Equals("NCop")); Assert.IsFalse(instance.IsDisposed); }
public TService TryResolve <TService>() { return(container.TryResolve <TService>()); }
public void DisposeOfContainer_OfDisposableNamedObjectWithAnArgumentWhichIsOwnedExternally_ReturnsTheNamedInstanceWithNotDispsoedIndication() { var container = new NCopContainer(registry => { registry.Register<IFoo, string>((c, name) => new Foo(name)) .Named("NCop") .OwnedExternally(); }); var instance = container.TryResolve<string, IFoo>("NCop", "NCop") as Foo; container.Dispose(); Assert.IsNotNull(instance); Assert.IsTrue(instance.Name.Equals("NCop")); Assert.IsFalse(instance.IsDisposed); }
public void TryResolve_NotRegisteredServiceWithMultipuleArguments_DontThrowsRegistrationExceptionAndReturnsNull() { var container = new NCopContainer(registry => { }); var instance = container.TryResolve<string, int, IFoo>("NCop", 9); Assert.IsNull(instance); }
public void TryResolve_NotRegisteredService_DontThrowsRegistrationExceptionAndReturnsNull() { var container = new NCopContainer(registry => { }); var instance = container.TryResolve<IFoo>(); Assert.IsNull(instance); }