Exemplo n.º 1
0
        private CodeCompileUnit GenerateCode(CodeGeneratorOptions options)
        {
            ICodeGeneratorContext codeGeneratorContext = new CodeGeneratorContext(metadataSet, options);

            WsdlImporterFactory wsdlImporterFactory = new WsdlImporterFactory(
                new XmlSerializerImportOptionsBuilder(),
                new XsdDataContractImporterBuilder(),
                new WrappedOptionsBuilder(),
                new FaultImportOptionsBuilder());

            ServiceContractGeneratorFactory contractGeneratorFactory = new ServiceContractGeneratorFactory(
                new ServiceContractGenerationOptionsBuilder());

            ICodeGenerator codeGenerator = new CodeGenerator(wsdlImporterFactory, contractGeneratorFactory);

            return(codeGenerator.GenerateCode(codeGeneratorContext));
        }
		public void GenerateCode_Builders_CalledWithContext()
		{
			ICodeGeneratorContext codeGeneratorContext = new CodeGeneratorContext(metadataSet, codeGeneratorOptions);

			Mock<IWsdlImporterBuilder> wsdlImportBuilder = new Mock<IWsdlImporterBuilder>();
			wsdlImportBuilder.Setup(mock => mock.Build(codeGeneratorContext))
				.Returns(new WsdlImporter(metadataSet)).AtMostOnce();

			Mock<IServiceContractGeneratorBuilder> contractGeneratorBuilder = new Mock<IServiceContractGeneratorBuilder>();
			Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
			contractGeneratorBuilder.Setup(mock => mock.Build(codeGeneratorContext))
				.Returns(new ServiceContractGenerator(codeGeneratorContext.CodeCompileUnit, configuration)).AtMostOnce();

			ICodeGenerator codeGenerator = new CodeGenerator(wsdlImportBuilder.Object, contractGeneratorBuilder.Object);
			codeGenerator.GenerateCode(codeGeneratorContext);

			wsdlImportBuilder.Verify();
			contractGeneratorBuilder.Verify();
		}
Exemplo n.º 3
0
        public void CodeGeneratorContextProvidedToFactoryMethods()
        {
            ICodeGeneratorContext codeGeneratorContext = new CodeGeneratorContext(metadataSet, codeGeneratorOptions);

            Mock <IWsdlImporterFactory> wsdlImporterFactory = new Mock <IWsdlImporterFactory>();

            wsdlImporterFactory.Setup(mock => mock.GetWsdlImporter(codeGeneratorContext))
            .Returns(new WsdlImporter(metadataSet)).AtMostOnce();

            Mock <IServiceContractGeneratorFactory> contractGeneratorFactory = new Mock <IServiceContractGeneratorFactory>();
            Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            contractGeneratorFactory.Setup(mock => mock.GetServiceContractGenerator(codeGeneratorContext))
            .Returns(new ServiceContractGenerator(codeGeneratorContext.CodeCompileUnit, configuration)).AtMostOnce();

            ICodeGenerator codeGenerator = new CodeGenerator(wsdlImporterFactory.Object, contractGeneratorFactory.Object);

            codeGenerator.GenerateCode(codeGeneratorContext);

            wsdlImporterFactory.Verify();
            contractGeneratorFactory.Verify();
        }
		private CodeCompileUnit GenerateCode(CodeGeneratorOptions options)
		{
			ICodeGeneratorContext codeGeneratorContext = new CodeGeneratorContext(metadataSet, options);

			WsdlImporterBuilder wsdlImporterBuilder = new WsdlImporterBuilder(
				new XmlSerializerImportOptionsBuilder(),
				new XsdDataContractImporterBuilder(),
				new WrappedOptionsBuilder(),
				new FaultImportOptionsBuilder());

			ServiceContractGeneratorBuilder contractGeneratorBuilder = new ServiceContractGeneratorBuilder(
				new ServiceContractGenerationOptionsBuilder());

			ICodeGenerator codeGenerator = new CodeGenerator(wsdlImporterBuilder, contractGeneratorBuilder);

			return codeGenerator.GenerateCode(codeGeneratorContext);
		}