public void ConstructWithAssembly() { Assembly assembly = Assembly.LoadFrom(@"../../../TestComp/bin/Debug/TestComp.dll"); DefaultNanoContainer nanoContainer = new DefaultNanoContainer(assembly); nanoContainer.RegisterComponentImplementation("test", "TestComp"); Assert.IsNotNull(nanoContainer.Pico.GetComponentInstance("test")); }
public void EnsureStandardTypesCanBeRegisteredByDefault() { DefaultNanoContainer nanoContainer = new DefaultNanoContainer(); string typeName = "System.Text.StringBuilder"; nanoContainer.RegisterComponentImplementation(typeName, typeName); Assert.IsNotNull(nanoContainer.Pico.GetComponentInstance(typeName)); }
public void TypesOutsideTheAssemblyShouldNotBeVisible() { Assembly assembly = Assembly.LoadFrom(@"../../../TestComp/bin/Debug/TestComp.dll"); DefaultNanoContainer nanoContainer = new DefaultNanoContainer(assembly); // This test should not be visible from the container nanoContainer.RegisterComponentImplementation(this.GetType().FullName); Assert.IsNotNull(nanoContainer.Pico.GetComponentInstance(this.GetType())); }
public void RegisterComponentByNameWithKey() { DefaultNanoContainer nanoContainer = new DefaultNanoContainer(); nanoContainer.RegisterComponentImplementation("webserver", "NanoContainer.Test.TestModel.DefaultWebServer"); nanoContainer.RegisterComponentImplementation("config", "NanoContainer.Test.TestModel.DefaultWebServerConfig"); Assert.IsNotNull(nanoContainer.Pico.GetComponentInstance("webserver")); Assert.IsNotNull(nanoContainer.Pico.GetComponentInstance("config")); }
public void RegisterComponentByName() { DefaultNanoContainer nanoContainer = new DefaultNanoContainer(); nanoContainer.RegisterComponentImplementation("NanoContainer.Test.TestModel.DefaultWebServer"); nanoContainer.RegisterComponentImplementation("NanoContainer.Test.TestModel.DefaultWebServerConfig"); Assert.IsNotNull(nanoContainer.Pico.GetComponentInstanceOfType(typeof(WebServer))); Assert.IsNotNull(nanoContainer.Pico.GetComponentInstance(typeof(DefaultWebServerConfig))); }
public void EnsureThatTypeFromExternalAssemblyIsNotFound() { DefaultNanoContainer nanoContainer = new DefaultNanoContainer(); nanoContainer.RegisterComponentImplementation("TestComp"); }
public void RegisterFailsForUnknownTypeName() { DefaultNanoContainer nanoContainer = new DefaultNanoContainer(); nanoContainer.RegisterComponentImplementation("this is not a valid type name"); }