public void RegisterComponentInstanceWithKey()
		{
			MockXMLContainerBuilder containerBuilder = new MockXMLContainerBuilder(null);
			string xml = @"<component-instance key='foo'>Bar</component-instance>";

			CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression();
			CodeVariableReferenceExpression cvre = new CodeVariableReferenceExpression();
			containerBuilder.CallRegisterComponentInstance(ConvertToXml(xml), cmie, cvre);

			Assert.AreEqual(Constants.REGISTER_COMPONENT_INSTANCE, cmie.Method.MethodName);
			Assert.AreEqual(2, cmie.Parameters.Count);
		}
		public void RegisterComponentImplementationWithoutKey()
		{
			MockXMLContainerBuilder containerBuilder = new MockXMLContainerBuilder(null);
			string xml = @"<component-implementation type='System.Text.StringBuilder'/>";

			CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression();
			CodeVariableReferenceExpression cvre = new CodeVariableReferenceExpression();
			containerBuilder.CallRegisterComponentImplementation(ConvertToXml(xml), cmie, cvre);

			Assert.AreEqual(Constants.REGISTER_COMPONENT_IMPLEMENTATION, cmie.Method.MethodName);
			Assert.AreEqual(1, cmie.Parameters.Count);
		}
		public void GetCompiledType()
		{
			string xml = @"
				<container>
					<component-instance key='Hello'>XML</component-instance>
					<component-instance key='Hei'>XMLContinerBuilder</component-instance>
				</container>";

			MockXMLContainerBuilder containerBuilder = new MockXMLContainerBuilder(ScriptFixture.BuildStreamReader(xml));
			IScript script = containerBuilder.CallCreateScript(new StringCollection());

			Assert.IsNotNull(script);
		}
		public void RegisterAssemblies()
		{
			MockXMLContainerBuilder containerBuilder = new MockXMLContainerBuilder(null);
			FileInfo testCompDll = new FileInfo(@"../../../TestComp/bin/Debug/TestComp.dll");
			FileInfo testComp2Dll = new FileInfo(@"../../../TestComp2/bin/Debug/TestComp2.dll");
			
			string xml = @"<assemblies>
						      <element file='" + testCompDll.FullName + @"'/>
						      <element url='" + new Uri("file://" + testComp2Dll) + @"'/>
						  </assemblies>";

			XmlElement classpathElement = ConvertToXml(xml);
			IList assemblies = new ArrayList();

			containerBuilder.CallRegisterAssemblies(classpathElement, assemblies);

			Assert.AreEqual(2, assemblies.Count);
		}
		public void RegisterAssembliesUnknownFileFails()
		{
			MockXMLContainerBuilder containerBuilder = new MockXMLContainerBuilder(null);
			
			string xml = @"<assemblies>
						      <element file='this.should.fail'/>
						  </assemblies>";

			containerBuilder.CallRegisterAssemblies(ConvertToXml(xml), new ArrayList());
		}
		public void RegisterComponentImplementationWithParameters()
		{
			MockXMLContainerBuilder containerBuilder = new MockXMLContainerBuilder(null);
			string xml = @"<component-implementation key='foo' type='BarClass'>
							<parameter key='param1'/>
				 		    <parameter key='param2'/>
						 </component-implementation>";

			CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression();
			CodeVariableReferenceExpression cvre = new CodeVariableReferenceExpression();
			containerBuilder.CallRegisterComponentImplementation(ConvertToXml(xml), cmie, cvre);

			Assert.AreEqual(Constants.REGISTER_COMPONENT_IMPLEMENTATION, cmie.Method.MethodName);
			Assert.AreEqual(3, cmie.Parameters.Count);
		}
		public void RegisterComponentImplementationFailsWithoutClassAttribute()
		{
			MockXMLContainerBuilder containerBuilder = new MockXMLContainerBuilder(null);
			string xml = @"<component-implementation noclassattribute='xxx'/>";

			CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression();
			CodeVariableReferenceExpression cvre = new CodeVariableReferenceExpression();
			containerBuilder.CallRegisterComponentImplementation(ConvertToXml(xml), cmie, cvre);
		}