public void ParseFailureNoApplicationDefinition(ApplicationDefinitionParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e)
        {
            "Given a model"
            .x(() =>
            {
                model = new AzureIntegrationServicesModel();
                group = CreateGroup();
                model.MigrationSource.MigrationSourceModel = group;

                var container = new ResourceContainer()
                {
                    Key = group.Applications[0].ResourceContainerKey, Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi"
                };
                model.MigrationSource.ResourceContainers.Add(container);
                var adf      = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ApplicationDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://Microsoft.BizTalk.ApplicationDeployment/ApplicationDefinition.xsd\">  <Properties>    <Property Name=\"DisplayName\" Value=\"SimpleMessagingApplication\" />    <Property Name=\"Guid\" Value=\"{319AC06C-0FAB-4B68-B2C9-2659DF322B63}\" />    <Property Name=\"Manufacturer\" Value=\"Generated by BizTalk Application Deployment\" />    <Property Name=\"Version\" Value=\"1.0.0.0\" />    <Property Name=\"ApplicationDescription\" Value=\"BizTalk Application 1\" />  </Properties>  <Resources>    <Resource Type=\"System.BizTalk:BizTalkBinding\" Luid=\"Application/SimpleMessagingApplication\">      <Properties>        <Property Name=\"IsDynamic\" Value=\"True\" />        <Property Name=\"IncludeGlobalPartyBinding\" Value=\"True\" />        <Property Name=\"ShortCabinetName\" Value=\"ITEM~0.CAB\" />        <Property Name=\"FullName\" Value=\"BindingInfo.xml\" />        <Property Name=\"Attributes\" Value=\"Archive\" />        <Property Name=\"CreationTime\" Value=\"2020-04-06 16:47:47Z\" />        <Property Name=\"LastAccessTime\" Value=\"2020-04-06 16:47:47Z\" />        <Property Name=\"LastWriteTime\" Value=\"2020-04-06 16:47:47Z\" />      </Properties>      <Files>        <File RelativePath=\"BindingInfo.xml\" Key=\"Binding\" />      </Files>    </Resource>  </Resources>  <References>    <Reference Name=\"BizTalk.System\" />    <Reference Name=\"Simple Referenced Application\" />  </References></ApplicationDefinition>";
                var resource = new ResourceDefinition()
                {
                    Key = "Applicatcation.adf.Key", Name = "ApplicationDefinition.adf", Type = ModelConstants.ResourceDefinitionApplicationDefinition, ResourceContent = adf
                };
                container.ResourceDefinitions.Add(resource);
            });

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

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

            "And a parser"
            .x(() => parser = new ApplicationDefinitionParser(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 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 application definition");
            });
        }
        public void ParseSuccessfulSingleFilterGroup(ApplicationDefinitionParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e)
        {
            "Given a model"
            .x(() =>
            {
                model = new AzureIntegrationServicesModel();
                group = CreateGroup();
                model.MigrationSource.MigrationSourceModel = group;

                var container = new ResourceContainer()
                {
                    Key = group.Applications[0].ResourceContainerKey, Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi"
                };
                model.MigrationSource.ResourceContainers.Add(container);
                var adf      = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ApplicationDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://Microsoft.BizTalk.ApplicationDeployment/ApplicationDefinition.xsd\">  <Properties>    <Property Name=\"DisplayName\" Value=\"SimpleMessagingApplication\" />    <Property Name=\"Guid\" Value=\"{319AC06C-0FAB-4B68-B2C9-2659DF322B63}\" />    <Property Name=\"Manufacturer\" Value=\"Generated by BizTalk Application Deployment\" />    <Property Name=\"Version\" Value=\"1.0.0.0\" />    <Property Name=\"ApplicationDescription\" Value=\"BizTalk Application 1\" />  </Properties>  <Resources>    <Resource Type=\"System.BizTalk:BizTalkBinding\" Luid=\"Application/SimpleMessagingApplication\">      <Properties>        <Property Name=\"IsDynamic\" Value=\"True\" />        <Property Name=\"IncludeGlobalPartyBinding\" Value=\"True\" />        <Property Name=\"ShortCabinetName\" Value=\"ITEM~0.CAB\" />        <Property Name=\"FullName\" Value=\"BindingInfo.xml\" />        <Property Name=\"Attributes\" Value=\"Archive\" />        <Property Name=\"CreationTime\" Value=\"2020-04-06 16:47:47Z\" />        <Property Name=\"LastAccessTime\" Value=\"2020-04-06 16:47:47Z\" />        <Property Name=\"LastWriteTime\" Value=\"2020-04-06 16:47:47Z\" />      </Properties>      <Files>        <File RelativePath=\"BindingInfo.xml\" Key=\"Binding\" />      </Files>    </Resource>  </Resources>  <References>    <Reference Name=\"BizTalk.System\" />    <Reference Name=\"Simple Referenced Application\" />  </References></ApplicationDefinition>";
                var resource = new ResourceDefinition()
                {
                    Key = "Applicatcation.adf.Key", Name = "ApplicationDefinition.adf", Type = ModelConstants.ResourceDefinitionApplicationDefinition, ResourceContent = adf
                };
                container.ResourceDefinitions.Add(resource);

                group.Applications[0].Application.ApplicationDefinition = new ApplicationDefinitionFile(container.Key, resource.Key);
            });

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

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

            "And a parser"
            .x(() => parser = new ApplicationDefinitionParser(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 filter group should be correctly parsed."
            .x(() =>
            {
                var applicationDefinition = group.Applications[0].Application.ApplicationDefinition.ApplicationDefinition;
                applicationDefinition.Should().NotBeNull();
                applicationDefinition.Properties.Length.Should().Be(5);
                applicationDefinition.Resources.Length.Should().Be(1);
                applicationDefinition.References.Length.Should().Be(2);
            });
        }
        public void ParseFailureEmptyXml(ApplicationDefinitionParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e)
        {
            "Given a model"
            .x(() =>
            {
                model = new AzureIntegrationServicesModel();
                group = CreateGroup();
                model.MigrationSource.MigrationSourceModel = group;

                var container = new ResourceContainer()
                {
                    Key = "Test.Key", Name = "Test", Type = ModelConstants.ResourceContainerCab, ContainerLocation = @"C:\Test\Test.CAB"
                };
                model.MigrationSource.ResourceContainers.Add(container);
                var adf      = string.Empty;
                var resource = new ResourceDefinition()
                {
                    Key = "Test.adf.Key", Name = "Test.adf", Type = ModelConstants.ResourceDefinitionApplicationDefinition, ResourceContent = adf
                };
                container.ResourceDefinitions.Add(resource);

                group.Applications[0].Application.ApplicationDefinition = new ApplicationDefinitionFile(container.Key, resource.Key);
            });

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

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

            "And a parser"
            .x(() => parser = new ApplicationDefinitionParser(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 parser should have recorded an error when processing the filter."
            .x(() =>
            {
                var item = group.Applications[0].Application.ApplicationDefinition.ApplicationDefinition.Should().BeNull();
                context.Errors.Count.Should().Be(1);
            });
        }
        public void ParseIsSkippedIfModelIsMissing(ApplicationDefinitionParser 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 ApplicationDefinitionParser(model, context, logger));

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

            "Then the code should not throw an exception"
            .x(() => e.Should().BeNull());
        }
        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 ApplicationDefinitionParser(model, context, logger)));

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