Esempio n. 1
0
        public void ParseOneSendPortAndValidReceiveData(PipelineDataParser parser, ILogger logger, List <SendPort> sendPorts, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e)
        {
            "Given a model with one send port and valid receive data XML"
            .x(() =>
            {
                model     = new AzureIntegrationServicesModel();
                sendPorts = new List <SendPort> {
                    new SendPort()
                };
                sendPorts[0].ReceivePipelineData = ValidData;
                group = CreateGroup(sendPorts.ToArray());
                model.MigrationSource.MigrationSourceModel = group;
            });

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

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

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

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

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

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

            "And there should be valid receive configuration"
            .x(() =>
            {
                sendPorts[0].ReceivePipelineCustomConfiguration.Should().NotBeNull();
                sendPorts[0].ReceivePipelineCustomConfiguration.Stages.Should().HaveCount(1);

                var rootStage = sendPorts[0].ReceivePipelineCustomConfiguration.Stages.FirstOrDefault();
                rootStage.Components.Should().NotBeNull();
                rootStage.Components[0].Should().NotBeNull();
                rootStage.Components[0].Name.Should().NotBeNullOrWhiteSpace();

                rootStage.Components[0].Properties.Should().HaveCount(1);
                var property = rootStage.Components[0].Properties.SingleOrDefault();
                property.Should().NotBeNull();
                property.Name.Should().NotBeNullOrWhiteSpace();
                property.Value.Should().NotBeNullOrWhiteSpace();
                property.ValueType.Should().NotBeNullOrWhiteSpace();
            });

            "And there should be no send configuration"
            .x(() =>
            {
                sendPorts[0].SendPipelineCustomConfiguration.Should().BeNull();
            });
        }
Esempio n. 2
0
        public void ParseSuccessfulOneSendPort(PipelineDataParser parser, ILogger logger, List <SendPort> sendPorts, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e)
        {
            "Given a model with one send port"
            .x(() =>
            {
                model     = new AzureIntegrationServicesModel();
                sendPorts = new List <SendPort> {
                    new SendPort()
                };
                group = CreateGroup(sendPorts.ToArray());
                model.MigrationSource.MigrationSourceModel = group;
            });

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

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

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

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

            "Then the code should not throw an exception"
            .x(() => e.Should().BeNull());
        }
Esempio n. 3
0
        public void ParseFailureNoBindings(PipelineDataParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e)
        {
            "Given a model"
            .x(() =>
            {
                model = new AzureIntegrationServicesModel();
                group = CreateGroup(Array.Empty <SendPort>());
                model.MigrationSource.MigrationSourceModel = group;
                group.Applications[0].Application.Bindings = null;     // Blank bindings forces a skip in processing.
            });

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

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

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

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

            "And the model should be parsed with a warning."
            .x(() =>
            {
                // There should be no exception logged - this is a handled scenario.
                context.Errors.Count.Should().Be(0);

                // The application definition cannot be read and so the name should be default
                var group = (ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel;
                group.Applications[0].Application.Name.Should().Be("(Unknown)");

                // An error should be logged
                var invocation = _mockLogger.Invocations.Where(i => i.Arguments[0].ToString() == "Warning").FirstOrDefault();
                invocation.Should().NotBeNull();
                invocation.Arguments[2].ToString().Should().Contain("Unable to find the binding info resource");
            });
        }
Esempio n. 4
0
        public void ParseIsSkippedIfModelIsMissing(SendPortPipelineDataParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e)
        {
            "Given a model"
            .x(() =>
            {
                model = new AzureIntegrationServicesModel();
            });

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

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

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

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

            "Then the code should not throw an exception"
            .x(() => e.Should().BeNull());
        }
Esempio n. 5
0
        public void ParseOneSendPortAndInvalidSendData(PipelineDataParser parser, ILogger logger, List <SendPort> sendPorts, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e)
        {
            "Given a model with one send port and invalid send data XML"
            .x(() =>
            {
                model     = new AzureIntegrationServicesModel();
                sendPorts = new List <SendPort> {
                    new SendPort()
                };
                sendPorts[0].SendPipelineData = "Invalid XML";
                group = CreateGroup(sendPorts.ToArray());
                model.MigrationSource.MigrationSourceModel = group;
            });

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

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

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

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

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

            "And there should be one error"
            .x(() =>
            {
                context.Errors.Should().HaveCount(1);
                context.Errors[0].Message.Should().Contain("Send");
            });
        }
Esempio n. 6
0
        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 SendPortPipelineDataParser(model, context, logger)));

            "Then the parser constructor should succeed"
            .x(() =>
            {
                e.Should().BeNull();
                parser.Should().NotBeNull();
            });
        }