private static ServiceContractGenerator GetServiceContractGenerator(ICodeGeneratorContext codeGeneratorContext)
        {
            Mock <IServiceContractGenerationOptionsBuilder> generationOptionsBuilder = new Mock <IServiceContractGenerationOptionsBuilder>();
            IServiceContractGeneratorFactory factory = new ServiceContractGeneratorFactory(generationOptionsBuilder.Object);

            return(factory.GetServiceContractGenerator(codeGeneratorContext));
        }
        public void Build_Options_CreatedByOptionsBuilder()
        {
            ICodeGeneratorContext codeGeneratorContext = new CodeGeneratorContext(metadataSet, new CodeGeneratorOptions());
            const ServiceContractGenerationOptions serviceContractGenerationOptions = new ServiceContractGenerationOptions();

            Mock <IServiceContractGenerationOptionsBuilder> generationOptionsBuilder = new Mock <IServiceContractGenerationOptionsBuilder>();

            generationOptionsBuilder.Setup(mock => mock.Build(codeGeneratorContext.CodeGeneratorOptions)).Returns(serviceContractGenerationOptions);

            IServiceContractGeneratorFactory factory           = new ServiceContractGeneratorFactory(generationOptionsBuilder.Object);
            ServiceContractGenerator         contractGenerator = factory.GetServiceContractGenerator(codeGeneratorContext);

            Assert.That(contractGenerator.Options, Is.EqualTo(serviceContractGenerationOptions));

            generationOptionsBuilder.Verify();
        }
예제 #3
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));
        }