public void ConstructWithNullModel(IBizTalkParser parser, ILogger logger, IApplicationModel model, MigrationContext context, Exception e)
        {
            "Given a parser"
            .x(() => parser.Should().BeNull());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And null model"
            .x(() => model.Should().BeNull());

            "And a context"
            .x(() => context = new MigrationContext());

            "When constructing with null model"
            .x(() => e = Record.Exception(() => new DistributionListParser(model, context, logger)));

            "Then the parser constructor should throw an exception"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("model"));
        }
        public void ConstructWithNullLogger(IBizTalkParser parser, ILogger logger, IApplicationModel model, MigrationContext context, Exception e)
        {
            "Given a parser"
            .x(() => parser.Should().BeNull());

            "And null logger"
            .x(() => logger.Should().BeNull());

            "And a model"
            .x(() => model = new AzureIntegrationServicesModel());

            "And a context"
            .x(() => context = new MigrationContext());

            "When constructing with null logger"
            .x(() => e = Record.Exception(() => new OrchestrationServiceDeclarationParser(model, context, logger)));

            "Then the parser constructor should throw an exception"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("logger"));
        }
Esempio n. 3
0
        public void ConstructWithNullContext(IBizTalkParser parser, ILogger logger, IApplicationModel model, MigrationContext context, Exception e)
        {
            "Given a parser"
            .x(() => parser.Should().BeNull());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And a model"
            .x(() => model = new AzureIntegrationServicesModel());

            "And a null context"
            .x(() => context.Should().BeNull());

            "When constructing with null context"
            .x(() => e = Record.Exception(() => new SendPortPipelineDataParser(model, context, logger)));

            "Then the parser constructor should throw an exception"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("context"));
        }
        public void ConstructWithSuccess(IBizTalkParser parser, ILogger logger, IApplicationModel model, MigrationContext context, Exception e)
        {
            "Given a parser"
            .x(() => parser.Should().BeNull());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And a model"
            .x(() => model = new AzureIntegrationServicesModel());

            "And a context"
            .x(() => context = new MigrationContext());

            "When constructing"
            .x(() => e = Record.Exception(() => parser = new DistributionListParser(model, context, logger)));

            "Then the parser constructor should succeed"
            .x(() =>
            {
                e.Should().BeNull();
                parser.Should().NotBeNull();
            });
        }
        /// <summary>
        /// Runs the stage runner.
        /// </summary>
        /// <param name="state">The execution state.</param>
        /// <param name="token">A cancellation token used to cancel this operation.</param>
        /// <returns>A task used to await the operation.</returns>
        protected override async Task InvokeRunAsync(IRunState state, CancellationToken token)
        {
            _ = state ?? throw new ArgumentNullException(nameof(state));

            var parsers = new IBizTalkParser[]
            {
                Container.GetRequiredService <BizTalkOrchestrationParser>(),
                Container.GetRequiredService <OrchestrationCorrelationTypeParser>(),
                Container.GetRequiredService <OrchestrationMultiPartMessageTypeParser>(),
                Container.GetRequiredService <OrchestrationPortTypeParser>(),
                Container.GetRequiredService <OrchestrationServiceLinkTypeParser>(),
                Container.GetRequiredService <OrchestrationServiceDeclarationParser>(),
            };

            _logger.LogTrace(TraceMessages.RunningDependencyRulesAnalyzer, parsers.Length);

            // Parse definition (should be async)
            foreach (var parser in parsers)
            {
                parser.Parse();
            }

            await Task.CompletedTask.ConfigureAwait(false);
        }
Esempio n. 6
0
        static void Main()
        {
            using (var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Trace)))
            {
                var logger = loggerFactory.CreateLogger <Program>();

                var outputPath = @"../../../../../output/";
                outputPath = Path.GetFullPath(outputPath);

                var context = new MigrationContext()
                {
                    WorkingFolder = outputPath
                };

                // Paths to the MSI test files
                var msiPaths = new string[]
                {
                    @"../../../../../tests/BTS2010FlatFilePipelineSample.msi",
                    @"../../../../../tests/BTS2020SimpleMessagingApplication.msi",
                    @"../../../../../tests/BTS2020SimpleReferencedApplication.msi",
                    @"../../../../../tests/BTS2020SimplePipelineDataApplication.msi",

                    // Path to scenarios MSI
                    @"../../../../../scenarios/001-FtpPassthru/msi/Aim.FtpPassthru.msi",
                    @"../../../../../scenarios/002-XmlMapping/msi/XmlMapping.msi",
                    @"../../../../../scenarios/003-SimpleOrchestration/msi/Aim.SimpleOrchestration.msi",
                    @"../../../../../scenarios/004-HttpJsonOrch/msi/Aim.HttpJsonOrch.msi",
                };

                // New application model
                var model = new AzureIntegrationServicesModel();

                // New run state
                var state = new RunState(new RunnerConfiguration(), model);

                // Create the input criteria (paths to the MSIs)
                foreach (var path in msiPaths)
                {
                    var pathInfo = new FileInfo(path);
                    model.MigrationSource.ResourceContainers.Add(new ResourceContainer()
                    {
                        Key = pathInfo.Name, Name = pathInfo.Name, Type = ModelConstants.ResourceContainerMsi, ContainerLocation = pathInfo.FullName
                    });
                }

                // Setup the discoverers.
                var discoverers = new IBizTalkDiscoverer[]
                {
                    new MsiDiscoverer(new FileRepository(), model, context, logger),
                    new AssemblyDiscoverer(model, context, logger)
                };

                logger.LogInformation(InformationMessages.DiscoveringStarted);

                // Run the discoverers.
                foreach (var discoverer in discoverers)
                {
                    discoverer.Discover();
                }

                logger.LogInformation(InformationMessages.DiscoveringComplete);

                // Setup the parsers
                var parsers = new IBizTalkParser[]
                {
                    // Parse the application definition file
                    new ApplicationDefinitionParser(model, context, logger),
                    // Parse the application name
                    new BizTalkApplicationParser(model, context, logger),
                    // Parse the module Refs
                    new BindingFileParser(model, context, logger),
                    // Parse the send port
                    new SendPortParser(model, context, logger),
                    // Parse the Orchestration Odx contents.
                    new BizTalkOrchestrationParser(model, context, logger),
                    // Parse the send port group filters
                    new DistributionListParser(model, context, logger),
                    // Parse the pipelines
                    new BizTalkPipelineParser(model, context, logger),
                    // Parse the property schemas
                    new PropertySchemaPropertyParser(model, context, logger),
                    // Parse the document schemas
                    new DocumentSchemaParser(model, context, logger),
                    // Parse the send pipeline data
                    new SendPortPipelineDataParser(model, context, logger),
                    // Parse the receive pipeline data
                    new ReceivePortPipelineDataParser(model, context, logger),
                    // Parse the receive port
                    new ReceivePortParser(model, context, logger),
                    // Parse the transforms
                    new TransformParser(model, context, logger),
                    // Parse the pipeline components
                    new PipelineComponentParser(model, context, logger),
                    // Parse the orchestration correlation types
                    new OrchestrationCorrelationTypeParser(model, context, logger),
                    // Parse the orchestration port types
                    new OrchestrationPortTypeParser(model, context, logger),
                    // Parse the orchestration multi part message types
                    new OrchestrationMultiPartMessageTypeParser(model, context, logger),
                    // Parse the orchestration service declarations
                    new OrchestrationServiceDeclarationParser(model, context, logger)
                };

                logger.LogInformation(InformationMessages.ParsingStarted);

                foreach (var parser in parsers)
                {
                    parser.Parse();
                }

                logger.LogInformation(InformationMessages.ParsingComplete);

                var analyzers = new IBizTalkAnalyzer[]
                {
                    new DP001SchemaDependencyAnalyzer(model, context, logger),
                    new DP002TransformDependencyAnalyzer(model, context, logger),
                    new DP003OrchestrationDependencyAnalyzer(model, context, logger),
                    new DP004ApplicationDependencyAnalyzer(model, context, logger),
                    new DP005DistributionListDependencyAnalyzer(model, context, logger),
                    new DP006ParentChildDependencyAnalyzer(model, context, logger),
                    new MB001MessageBusAnalyzer(model, context, logger),
                    new AP001ApplicationAnalyzer(model, context, logger),
                    new AP002SystemApplicationAnalyzer(model, context, logger),
                    new MB002MessageBoxAnalyzer(model, context, logger),
                    new SC001SchemaAnalyzer(model, context, logger),
                    new SC002PropertySchemaAnalyzer(model, context, logger)
                };

                logger.LogInformation(InformationMessages.AnalysisStarted);

                foreach (var analyzer in analyzers)
                {
                    var task = analyzer.AnalyzeAsync(CancellationToken.None);
                    task.Wait();
                }

                logger.LogInformation(InformationMessages.AnalysisComplete);

                logger.LogInformation(InformationMessages.ReportingStarting);

                var reportWriter = new FileReportWriter();
                context.ReportFilePath = Path.Combine(context.WorkingFolder, "BizTalkMigrationReport.html");
                var reporters = new IBizTalkReporter[]
                {
                    new HtmlReportFormatter(model, context, state, reportWriter, logger)
                };

                foreach (var reporter in reporters)
                {
                    reporter.Report();
                }

                logger.LogInformation(InformationMessages.ReportingComplete);

                // Output the results
                var serializer = new JsonSerializer();
                using var writer = new StringWriter();
                serializer.Serialize(writer, model);
                File.WriteAllText(Path.Combine(context.WorkingFolder, "model.json"), writer.ToString());
            }
        }