public void ExternalInstancesBoom() { var d1 = new BuilderTests.Dep1(); var builder = new ContainerBuilder(); builder.Register(d1); builder.Register <GoBoom>(); ConstructorFaultedException dme = null; Assert.Throws <ConstructorFaultedException>(() => { try { builder.Build(); } catch (ConstructorFaultedException e) { dme = e; throw; } }); Assert.Equal(0, dme.Created.Count); }
public void ExternalInstances() { var d1 = new BuilderTests.Dep1(); var builder = new ContainerBuilder(); builder.Register(d1); builder.Register(typeof(BuilderTests.Dep3)); builder.Register <BuilderTests.DepB>(); DependencyMissingException dme = null; Assert.Throws <DependencyMissingException>(() => { try { builder.Build(); } catch (DependencyMissingException e) { dme = e; throw; } }); Assert.Equal(1, dme.Created.Count); Assert.IsType <BuilderTests.Dep3>(dme.Created[0]); }
public GoBoom(BuilderTests.Dep1 d1) { throw new DirectoryNotFoundException("boom"); }