コード例 #1
0
		public void InstantiateATypeFromAssemblyThatHasReferenceToAnotherAssembly()
		{
			StringCollection assemblies = new StringCollection();
			assemblies.Add("../../../TestCompWithAttributes/bin/Debug/TestCompWithAttributes.dll");
			
			ContainerBuilderFacade cbf = new AttributeBasedContainerBuilderFacade();
			IMutablePicoContainer picoContainer = cbf.Build(assemblies);
			Assert.AreEqual(1, picoContainer.ComponentInstances.Count);
			object instance = picoContainer.GetComponentInstance("testcomp3-key");
			
			Assert.AreEqual("TestComp3", instance.GetType().FullName); // from the assembly passed in
			Assert.AreEqual("TestComp", instance.GetType().BaseType.FullName); // base type from a second externally assembly
		}
コード例 #2
0
		public void BuildContainerFromMoreThanOneAssembly()
		{
			StringCollection assemblies = new StringCollection();
			assemblies.Add("../../../TestCompWithAttributes/bin/Debug/TestCompWithAttributes.dll");
			assemblies.Add("../../../NotStartable/bin/Debug/NotStartable.dll");
			
			IMutablePicoContainer parent = new DefaultPicoContainer();
			parent.RegisterComponentInstance(new StringBuilder("This is needed for type NotStartable"));

			ContainerBuilderFacade cbf = new AttributeBasedContainerBuilderFacade();
			IMutablePicoContainer picoContainer = cbf.Build(parent, assemblies);

			Assert.IsNotNull(picoContainer.GetComponentInstance("testcomp3-key"));
			Assert.IsNotNull(picoContainer.GetComponentInstance("notstartable"));
		}
コード例 #3
0
		public void SetUp()
		{
			ContainerBuilderFacade containerBuilderFacade = new AttributeBasedContainerBuilderFacade();
			picoContainer = containerBuilderFacade.Build(new string[] {"NanoContainer.Tests.dll"});
		}