public void BuildUpWithIdIsContainerManagedAndSingleton() { BuilderContainer container = new BuilderContainer(); Foo f = container.BuildUp <Foo>("foo"); Foo f2 = container.BuildUp <Foo>("foo"); Assert.AreSame(f, f2); }
public void CanAskContainerContainsById() { BuilderContainer container = new BuilderContainer(); Foo f = container.BuildUp <Foo>("Foo"); Assert.IsTrue(container.Contains("Foo")); }
public void CannotSetComponentNameThroughSite() { BuilderContainer container = new BuilderContainer(); Component component = container.BuildUp <Component>("Foo"); component.Site.Name = "Bar"; }
public void CanAskContainerContainsByTypeAndId() { BuilderContainer container = new BuilderContainer(); Foo f = container.BuildUp <Foo>("Foo"); Assert.IsTrue(container.Contains(typeof(Foo), "Foo")); }
public void CanBuildObject() { BuilderContainer container = new BuilderContainer(); Foo f = container.BuildUp <Foo>(); Assert.IsNotNull(f); }
public void BuildSetsSite() { BuilderContainer container = new BuilderContainer(); Component component = container.BuildUp <Component>("Foo"); Assert.IsNotNull(component.Site); }
public void SiteNameMatchesBuiltId() { BuilderContainer container = new BuilderContainer(); Component component = container.BuildUp <Component>("Foo"); Assert.AreEqual("Foo", component.Site.Name); }
public void BuildUpWithoutIdIsNotContainerManaged() { BuilderContainer container = new BuilderContainer(); Foo f = container.BuildUp <Foo>(); Assert.IsNotNull(f); Assert.IsFalse(((ILifetimeContainer)container).Contains(f)); }
public void DisposedEventListenedByContainerForSingletonObject() { BuilderContainer container = new BuilderContainer(); DisposableFoo foo = container.BuildUp <DisposableFoo>("Foo"); foo.Dispose(); Assert.IsFalse(container.Contains("Foo")); }
public void GetServiceLocatesInContainerByType() { BuilderContainer container = new BuilderContainer(); FooComponent component = container.BuildUp <FooComponent>("Foo"); object service = component.GetService <ILifetimeContainer>(); Assert.IsNotNull(service); }
public void DisposeRemovesFromContainer() { BuilderContainer container = new BuilderContainer(); Component component = container.BuildUp <Component>("Foo"); component.Dispose(); Assert.IsFalse(container.Contains("Foo")); }
public void DisposedEventListenedByContainerForSingletonComponent() { BuilderContainer container = new BuilderContainer(); Component c1 = container.BuildUp <Component>("Foo"); c1.Dispose(); Assert.IsFalse(container.Contains("Foo")); }
public void DisposeRemovesSite() { BuilderContainer container = new BuilderContainer(); Component component = container.BuildUp <Component>("Foo"); component.Dispose(); Assert.IsNull(component.Site); }
public void CanRegisterImplementationType() { BuilderContainer container = new BuilderContainer(); container.Register <IFoo, Foo>(); IFoo foo = container.BuildUp <IFoo>(); Assert.IsTrue(foo is Foo); }
public void DisposingContainerDisposesManagedSingletonObjects() { bool disposed = false; BuilderContainer container = new BuilderContainer(); Component c1 = container.BuildUp <Component>("Foo"); c1.Disposed += delegate { disposed = true; }; container.Dispose(); Assert.IsTrue(disposed); }
public void DisposingContainerDoesNotDisposeNonSingletons() { bool disposed = false; BuilderContainer container = new BuilderContainer(); Component c1 = container.BuildUp <Component>(); c1.Disposed += delegate { disposed = true; }; container.Dispose(); Assert.IsFalse(disposed); }
public void ApplyBuilderWithIdIsContainerManagedAndSingleton() { BuilderContainer container = new BuilderContainer(); Foo f = new Foo(); container.ApplyBuilder <Foo>(f, "foo"); Foo f2 = container.BuildUp <Foo>("foo"); Assert.IsTrue(((ILifetimeContainer)container).Contains(f)); Assert.AreSame(f, f2); }