public void RegistersTests_ComposeBy_Generic() { IStashboxContainer container = new StashboxContainer(); container.ComposeBy <TestCompositionRoot>(); var regs = container.ContainerContext.RegistrationRepository.GetAllRegistrations().OrderBy(r => r.RegistrationNumber).ToArray(); Assert.AreEqual(2, regs.Length); Assert.AreSame(regs[0].ImplementationType, typeof(Test)); Assert.AreSame(regs[1].ImplementationType, typeof(Test1)); }
public void RegistersTests_ComposeBy() { IStashboxContainer container = new StashboxContainer(); container.ComposeBy(typeof(TestCompositionRoot)); var regs = container.ContainerContext.RegistrationRepository.GetRegistrationMappings().OrderBy(r => r.Value.RegistrationId).ToArray(); Assert.Equal(2, regs.Length); Assert.Same(regs[0].Value.ImplementationType, typeof(Test)); Assert.Same(regs[1].Value.ImplementationType, typeof(Test1)); }
public void ContainerTests_Throws_Disposed_Exceptions() { var container = new StashboxContainer(); container.Dispose(); Assert.Throws <ObjectDisposedException>(() => container.Activate(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.BeginScope()); Assert.Throws <ObjectDisposedException>(() => container.BuildUp(new object())); Assert.Throws <ObjectDisposedException>(() => container.CanResolve(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.ComposeAssemblies(new[] { this.GetType().GetTypeInfo().Assembly })); Assert.Throws <ObjectDisposedException>(() => container.ComposeAssembly(this.GetType().GetTypeInfo().Assembly)); Assert.Throws <ObjectDisposedException>(() => container.ComposeBy(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.Configure(c => { })); Assert.Throws <ObjectDisposedException>(() => container.CreateChildContainer()); Assert.Throws <ObjectDisposedException>(() => container.GetRegistrationMappings()); #if HAS_SERVICEPROVIDER Assert.Throws <ObjectDisposedException>(() => container.GetService(this.GetType())); #endif Assert.Throws <ObjectDisposedException>(() => container.IsRegistered(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.PutInstanceInScope(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.Register(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.RegisterAssemblies(new[] { this.GetType().GetTypeInfo().Assembly })); Assert.Throws <ObjectDisposedException>(() => container.RegisterAssembly(this.GetType().GetTypeInfo().Assembly)); Assert.Throws <ObjectDisposedException>(() => container.RegisterAssemblyContaining <ITest1>()); Assert.Throws <ObjectDisposedException>(() => container.RegisterDecorator(this.GetType(), this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.RegisterFunc <ITest1>(r => new Test1())); Assert.Throws <ObjectDisposedException>(() => container.RegisterInstance(new object())); Assert.Throws <ObjectDisposedException>(() => container.RegisterInstances(new object())); Assert.Throws <ObjectDisposedException>(() => container.RegisterResolver(null)); Assert.Throws <ObjectDisposedException>(() => container.RegisterScoped <ITest1, Test1>()); Assert.Throws <ObjectDisposedException>(() => container.RegisterSingleton <ITest1, Test1>()); Assert.Throws <ObjectDisposedException>(() => container.RegisterTypes(new [] { this.GetType() })); Assert.Throws <ObjectDisposedException>(() => container.RegisterTypesAs <ITest1>(this.GetType().GetTypeInfo().Assembly)); Assert.Throws <ObjectDisposedException>(() => container.ReMap <ITest1, Test1>()); Assert.Throws <ObjectDisposedException>(() => container.ReMapDecorator(this.GetType(), this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.Resolve(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.ResolveAll(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.ResolveFactory(this.GetType())); Assert.Throws <ObjectDisposedException>(() => container.Validate()); Assert.Throws <ObjectDisposedException>(() => container.WireUp(new object())); }
public void RegistersTests_ComposeBy_Throw_DoesntImplement_ICompositionRoot() { IStashboxContainer container = new StashboxContainer(); container.ComposeBy(typeof(Test)); }
public void RegistersTests_ComposeBy_Throw_DoesntImplement_ICompositionRoot() { IStashboxContainer container = new StashboxContainer(); Assert.Throws <ArgumentException>(() => container.ComposeBy(typeof(Test))); }