public void CreateSchemaWithSuccess(SC001SchemaAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given an analyzer"
            .x(() => analyzer.Should().BeNull());

            "And a model"
            .x(() => model = TestHelper.CreateDefaultModelForAnalyzing());

            "And the model has a migration target "
            .x(() =>
            {
                TestHelper.CopySourceToTarget(model);
            });

            "And the migration target has no messages"
            .x(() =>
            {
                foreach (var application in model.MigrationTarget.MessageBus.Applications)
                {
                    application.Messages.Clear();
                }
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

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

            "And an analyzer"
            .x(() => analyzer = new SC001SchemaAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then the constructor should NOT throw an exception"
            .x(() => e.Should().BeNull());

            "And the messages will have been created"
            .x(() =>
            {
                model.Should().NotBeNull();
                model.MigrationTarget.Should().NotBeNull();
                model.MigrationTarget.MessageBus.Should().NotBeNull();
                model.MigrationTarget.MessageBus.Applications.Should().HaveCount(3);

                model.MigrationTarget.MessageBus.Applications[0].Messages.Should().HaveCount(3);
                model.MigrationTarget.MessageBus.Applications[0].Messages[0].Name = "DocumentSchema1";
                model.MigrationTarget.MessageBus.Applications[0].Messages[0].Key  = "keyMessageBus: Test App 1:DocumentSchema1";
                model.MigrationTarget.MessageBus.Applications[0].Messages[1].Name = "DocumentSchema2";
                model.MigrationTarget.MessageBus.Applications[0].Messages[1].Key  = "keyMessageBus: Test App 1:DocumentSchema2";
            });
        }
Exemplo n.º 2
0
        public void SC002RuleRuleWithSuccess(SC002PropertySchemaAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given an source model"
            .x(() => model = TestHelper.CreateDefaultModelForAnalyzing());

            "And the model has a migration target "
            .x(() =>
            {
                TestHelper.CopySourceToTarget(model);
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

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

            "And an analyzer"
            .x(() => analyzer = new SC002PropertySchemaAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be no context errors"
            .x(() => context.Errors.Should().HaveCount(0));

            "And the routing properties should be set"
            .x(() =>
            {
                model.Should().NotBeNull();
                model.MigrationTarget.Should().NotBeNull();
                model.MigrationTarget.MessageBus.Should().NotBeNull();
                model.MigrationTarget.MessageBus.Applications.Should().HaveCount(3);

                model.MigrationTarget.MessageBus.Applications[0].Messages.Should().HaveCount(3);
                model.MigrationTarget.MessageBus.Applications[0].Messages[0].Name = "Test.Schemas.DocumentSchema1";
                model.MigrationTarget.MessageBus.Applications[0].Messages[0].RoutingProperties.Should().HaveCount(1);
                model.MigrationTarget.MessageBus.Applications[0].Messages[0].RoutingProperties.First().Key.Should().Be("Test.Schemas.PropertySchema1.Property1");
                model.MigrationTarget.MessageBus.Applications[0].Messages[0].RoutingProperties.First().Value.Should().Be("some xpath 1");

                model.MigrationTarget.MessageBus.Applications[0].Messages[1].Name = "Test.Schemas.DocumentSchema2";
                model.MigrationTarget.MessageBus.Applications[0].Messages[1].RoutingProperties.Should().HaveCount(0);
            });
        }
        public void FindChannelResourceWithNullModel(AzureIntegrationServicesModel model, string templateKey, TargetResourceTemplate resource, Exception e)
        {
            "Given a null model"
            .x(() => model.Should().BeNull());

            "And a template key"
            .x(() => templateKey = "messageBox");

            "When finding the resource template"
            .x(() => e = Record.Exception(() => resource = CustomLiquidFunctions.FindResourceTemplate(model, templateKey)));

            "Then the find should succeed"
            .x(() => e.Should().BeNull());

            "And the target resource should be null"
            .x(() => resource.Should().BeNull());
        }
Exemplo n.º 4
0
        public void CreateMapLinksWithSuccess(MA001TransformAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given an analyzer"
            .x(() => analyzer.Should().BeNull());

            "And a model"
            .x(() => model = TestHelper.CreateDefaultModelForAnalyzing());

            "And the model has a migration target "
            .x(() =>
            {
                TestHelper.CopySourceToTarget(model);
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

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

            "And an analyzer"
            .x(() => analyzer = new MA001TransformAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then the constructor should NOT throw an exception"
            .x(() => e.Should().BeNull());

            "And the messages will have been created"
            .x(() =>
            {
                model.Should().NotBeNull();
                model.MigrationTarget.Should().NotBeNull();
                model.MigrationTarget.MessageBus.Should().NotBeNull();
                model.MigrationTarget.MessageBus.Applications.Should().HaveCount(3);

                model.MigrationTarget.MessageBus.Applications[0].Messages.Should().HaveCount(3);

                model.MigrationTarget.MessageBus.Applications[0].Messages[0].MessageTransforms.Should().HaveCount(1);
                model.MigrationTarget.MessageBus.Applications[0].Messages[0].MessageTransforms[0].ResourceKeyRef.Should().Be("transform-1-resource");
            });
        }
        public void RenderTemplateAsyncWithModelNullError(ITemplateRenderer renderer, AzureIntegrationServicesModel model, string templateContent, string renderedContent, Exception e)
        {
            "Given a template renderer"
            .x(() => renderer = new LiquidTemplateRenderer(_mockLogger.Object));

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

            "And a template content"
            .x(() => templateContent = _templateContent);

            "When rendering the template"
            .x(async() => e = await Record.ExceptionAsync(async() => renderedContent = await renderer.RenderTemplateAsync(templateContent, model)));

            "Then the render should error"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("model"));

            "And the rendered content should not have a value"
            .x(() => renderedContent.Should().BeNull());
        }
Exemplo n.º 6
0
        public void RenderConfigurationAsyncWithModelNullError(IConfigurationRepository repository, AzureIntegrationServicesModel model, string sourcePath, string targetPath, Exception e)
        {
            "Given a repository"
            .x(() => repository = new FileConfigurationRepository(_mockRenderer.Object, _mockLogger.Object));

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

            "And a source path"
            .x(() => sourcePath = OkConfigPath);

            "And a target path"
            .x(() => targetPath = _tempOutputTemplatePath);

            "When getting the configuration with null model"
            .x(async() => e = await Record.ExceptionAsync(async() => await repository.RenderConfigurationAsync(model, sourcePath, targetPath)));

            "Then the render should error"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("model"));

            "And the output path should be empty"
            .x(() => Directory.GetFiles(targetPath, "*").Should().HaveCount(0));
        }
Exemplo n.º 7
0
        public void GenerateResourcesAsyncWithModelNullError(IResourceGenerator generator, AzureIntegrationServicesModel model, IList <YamlStream> config, Exception e)
        {
            "Given a resource generator"
            .x(() => generator = new YamlResourceGenerator(_mockLogger.Object));

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

            "And configuration"
            .x(async() =>
            {
                var renderer   = new LiquidTemplateRenderer(_mockLogger.Object);
                var repository = new FileConfigurationRepository(renderer, _mockLogger.Object);
                await repository.RenderConfigurationAsync(_model, OkMultiConfigPath, _tempOutputTemplatePath);
                config = repository.GetConfiguration(_tempOutputTemplatePath);
            });

            "When generating resources"
            .x(async() => e = await Record.ExceptionAsync(async() => await generator.GenerateResourcesAsync(model, config, _source.Token)));

            "Then the generation should error"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("model"));
        }
Exemplo n.º 8
0
        public void GenerateXmlSchema(SC001DocumentSchemaGenerator generator, IFileRepository fileRepository, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given an generator"
            .x(() => generator.Should().BeNull());

            "And a file repository"
            .x(() => fileRepository = _mockFileRepository.Object);

            "And a model"
            .x(() => model = TestHelper.CreateDefaultModelForConverting());

            "And a context"
            .x(() => context = TestHelper.BuildContext());

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

            "And an generator"
            .x(() => generator = new SC001DocumentSchemaGenerator(fileRepository, model, context, logger));

            "When generating"
            .x(async() => e = await Record.ExceptionAsync(async() => await generator.ConvertAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then the constructor should NOT throw an exception"
            .x(() => e.Should().BeNull());

            "And 1 schema has been created"
            .x(() =>
            {
                model.Should().NotBeNull();

                _mockFileRepository.Verify(r => r.WriteXmlFile(
                                               It.IsAny <string>(),
                                               It.IsAny <string>()),
                                           Times.Once);
            });
        }
Exemplo n.º 9
0
        public void RenderTemplateAsyncWithModelNullError(ISnippetRenderer renderer, AzureIntegrationServicesModel model, ProcessManager processManager, TargetResourceTemplate resourceTemplate, TargetResourceSnippet resourceSnippet, WorkflowObject workflowObject, string snippetContent, string renderedContent, Exception e)
        {
            "Given a snippet renderer"
            .x(() => renderer = new LiquidSnippetRenderer(_mockLogger.Object));

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

            "And a process manager"
            .x(() =>
            {
                var messagingObject = _model.FindMessagingObject("ContosoMessageBus:AppA:FtpTransformWorkflow");
                messagingObject.messagingObject.Should().NotBeNull().And.BeOfType(typeof(ProcessManager));
                processManager   = (ProcessManager)messagingObject.messagingObject;
                resourceTemplate = processManager.Resources.First();
                resourceSnippet  = processManager.Snippets.First();
            });

            "And a workflow object"
            .x(() =>
            {
                workflowObject = processManager.WorkflowModel.Activities.First();
            });

            "And a snippet content"
            .x(() => snippetContent = _snippetContent);

            "When rendering the template"
            .x(async() => e = await Record.ExceptionAsync(async() => renderedContent = await renderer.RenderSnippetAsync(snippetContent, model, processManager, resourceTemplate, resourceSnippet, workflowObject)));

            "Then the render should error"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("model"));

            "And the rendered content should not have a value"
            .x(() => renderedContent.Should().BeNull());
        }
Exemplo n.º 10
0
        public void ParseSuccessfulSingleSendPipelineComponent(PipelineComponentParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e)
        {
            var sendPiplineDefinitionName         = "sendPiplineDefinitionName ";
            var sendPipelineDefinitionKey         = "sendPipelineDefinitionKey";
            var sendPipelineDefinitionDescription = "sendPipelineDescription";
            var sendPipelineResourceKey           = "sendPipelineResourceKey";
            var sendPipelineResourceName          = "sendPipelineResourceName";
            var sendPipelineComponentName         = "sendPipelineComponentName";
            var sendPipelineComponentDescription  = "sendPipelineComponentDescription";

            "Given a source model with a send pipeline and component"
            .x(() =>
            {
                var pipelineComponentDocument = new Document
                {
                    Stages = new DocumentStage[]
                    {
                        new DocumentStage
                        {
                            Components = new DocumentStageComponent[1]
                            {
                                new DocumentStageComponent {
                                    ComponentName = sendPipelineComponentName, Description = sendPipelineComponentDescription
                                }
                            }
                        }
                    }
                };

                var sendPipeline = new Pipeline
                {
                    Name = sendPiplineDefinitionName,
                    ResourceDefinitionKey = sendPipelineDefinitionKey,
                    Direction             = PipelineDirection.Send,
                    Description           = sendPipelineDefinitionDescription,
                    Document    = pipelineComponentDocument,
                    ResourceKey = sendPipelineResourceKey
                };

                var parsedApplication = new ParsedBizTalkApplication
                {
                    Application = new BizTalkApplication()
                };

                parsedApplication.Application.Pipelines.Add(sendPipeline);

                var aisModel = new AzureIntegrationServicesModel();
                var group    = new ParsedBizTalkApplicationGroup();
                aisModel.MigrationSource.MigrationSourceModel = group;
                group.Applications.Add(parsedApplication);

                model = aisModel;
            });

            "And one send pipeline resource in the source model"
            .x(() =>
            {
                var msiReportContainer = new ResourceContainer
                {
                    Type = ModelConstants.ResourceContainerMsi,
                    Key  = "msiContainerKey",
                    Name = "msiContainerName"
                };

                var cabReportContainer = new ResourceContainer
                {
                    Type = ModelConstants.ResourceContainerCab,
                    Key  = "cabContainerKey",
                    Name = "cabContainerName"
                };

                var assemblyReportContainer = new ResourceContainer
                {
                    Type = ModelConstants.ResourceContainerAssembly,
                    Key  = "assemblyContainerKey",
                    Name = "assemblyContainerName"
                };

                var sendPipelineReportDefinition = new ResourceDefinition
                {
                    Type = ModelConstants.ResourceDefinitionOrchestration,
                    Key  = sendPipelineDefinitionKey,
                    Name = sendPiplineDefinitionName
                };

                var sendPipelineResource = new ResourceItem
                {
                    Type = ModelConstants.ResourceSendPipeline,
                    Name = sendPipelineResourceName,
                    Key  = sendPipelineResourceKey
                };

                sendPipelineReportDefinition.Resources.Add(sendPipelineResource);
                assemblyReportContainer.ResourceDefinitions.Add(sendPipelineReportDefinition);
                cabReportContainer.ResourceContainers.Add(assemblyReportContainer);
                msiReportContainer.ResourceContainers.Add(cabReportContainer);

                model.MigrationSource.ResourceContainers.Add(msiReportContainer);
            });

            "And a logger"
            .x(() => logger = new Mock <ILogger>().Object);

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

            "And a parser"
            .x(() => parser = new PipelineComponentParser(model, context, logger));

            "When parsing"
            .x(() => e = Record.Exception(() => parser.Parse()));

            "Then the code should not throw an exception"
            .x(() => e.Should().BeNull());

            "And the source model should have a pipeline component under the send pipeline resource in the source report"
            .x(() =>
            {
                model.Should().NotBeNull();
                model.MigrationSource.Should().NotBeNull();
                model.MigrationSource.ResourceContainers[0].Should().NotBeNull();
                model.MigrationSource.ResourceContainers[0].ResourceContainers[0].Should().NotBeNull();
                model.MigrationSource.ResourceContainers[0].ResourceContainers[0].ResourceContainers[0].Should().NotBeNull();
                model.MigrationSource.ResourceContainers[0].ResourceContainers[0].ResourceContainers[0].ResourceDefinitions.Should().NotBeNull();
                model.MigrationSource.ResourceContainers[0].ResourceContainers[0].ResourceContainers[0].ResourceDefinitions.Should().HaveCount(1);
                var sendPipeline = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Pipelines[0];

                var sendPipelineDefinition = model.MigrationSource.ResourceContainers[0].ResourceContainers[0].ResourceContainers[0].ResourceDefinitions[0];
                sendPipelineDefinition.Resources.Should().NotBeNull();
                sendPipelineDefinition.Resources.Should().HaveCount(1);

                // Validate the send pipeline.
                var sendPipelineResource = sendPipelineDefinition.Resources[0];
                sendPipelineResource.Resources.Should().NotBeNull();
                sendPipelineResource.Resources.Should().HaveCount(1);

                // Validate the pipeline components.
                var pipelineComponentResource = sendPipelineResource.Resources[0];
                pipelineComponentResource.Type.Should().Be(ModelConstants.ResourcePipelineComponent);
                pipelineComponentResource.Name.Should().Be(sendPipelineComponentName);
                pipelineComponentResource.Description.Should().Be(sendPipelineComponentDescription);
                pipelineComponentResource.Key.Should().Be(string.Concat(sendPipelineResource.Key, ":", pipelineComponentResource.Name));

                sendPipeline.Document.Stages[0].Components[0].Resource.Should().Be(pipelineComponentResource); // The pointer to the resource should be set.
                pipelineComponentResource.ParentRefId.Should().Be(sendPipelineResource.RefId);                 // The parent ref ID should be set.
                var stageComponents = Document.FindStageComponents(sendPipeline.Document);
                pipelineComponentResource.SourceObject.Should().Be(stageComponents.First());                   // The resource should have a pointer to the source object.
            });
        }