コード例 #1
0
		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"));
		}
コード例 #2
0
		public void EnsureStandardTypesCanBeRegisteredByDefault()
		{
			DefaultNanoContainer nanoContainer = new DefaultNanoContainer();
			string typeName = "System.Text.StringBuilder";
			
			nanoContainer.RegisterComponentImplementation(typeName, typeName);
			Assert.IsNotNull(nanoContainer.Pico.GetComponentInstance(typeName));
		}
コード例 #3
0
		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()));
		}
コード例 #4
0
		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"));
		}
コード例 #5
0
		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)));
		}
コード例 #6
0
		public void EnsureThatTypeFromExternalAssemblyIsNotFound()
		{
			DefaultNanoContainer nanoContainer = new DefaultNanoContainer();
			nanoContainer.RegisterComponentImplementation("TestComp");
		}
コード例 #7
0
		public void RegisterFailsForUnknownTypeName()
		{
			DefaultNanoContainer nanoContainer = new DefaultNanoContainer();
			nanoContainer.RegisterComponentImplementation("this is not a valid type name");
		}