public void ParseFailureInvalidXml(BizTalkApplicationParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e) { "Given a model" .x(() => { model = new AzureIntegrationServicesModel(); group = new ParsedBizTalkApplicationGroup(); group.Applications.Add(new ParsedBizTalkApplication() { ResourceContainerKey = "MSI.key" }); model.MigrationSource.MigrationSourceModel = group; var container = new ResourceContainer() { Name = "Test", Key = "MSI.key", Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi" }; model.MigrationSource.ResourceContainers.Add(container); var adf = "<this is not xml>"; var resource = new ResourceDefinition() { Key = "ADF.Key", Name = "ApplicationDefinition", 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 BizTalkApplicationParser(model, context, logger)); "When parsing with invalid XML in the bindings file" .x(() => e = Record.Exception(() => parser.Parse())); "Then the parser should not throw an exception" .x(() => e.Should().BeNull()); "And there should be an exception when parsing." .x(() => { // There should be an exception logged. context.Errors.Count.Should().Be(1); // 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() == "Error").FirstOrDefault(); invocation.Should().NotBeNull(); invocation.Arguments[2].ToString().Should().Contain("An error occurred reading application from application definition file"); }); }
public void ParseFailureApplicationNameBlank(BizTalkApplicationParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e) { "Given a model" .x(() => { model = new AzureIntegrationServicesModel(); group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; group.Applications.Add(new ParsedBizTalkApplication() { ResourceContainerKey = "TestMsi.Key", }); model.MigrationSource.MigrationSourceModel = group; var msiContainer = new ResourceContainer() { Key = "TestMsi.Key", Name = "TestMsi", Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi" }; model.MigrationSource.ResourceContainers.Add(msiContainer); 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=\"\" /> <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 = "ApplicationDefinition.adf.Key", Name = "ApplicationDefinition.adf", Type = ModelConstants.ResourceDefinitionApplicationDefinition, ResourceContent = adf }; msiContainer.ResourceDefinitions.Add(resource); group.Applications[0].Application.ApplicationDefinition = new ApplicationDefinitionFile(msiContainer.Key, resource.Key); }); "And a logger" .x(() => logger = _mockLogger.Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new BizTalkApplicationParser(model, context, logger)); "When parsing" .x(() => e = Record.Exception(() => parser.Parse())); "Then the parser should not throw an exception" .x(() => e.Should().BeNull()); "And the context should have an error." .x(() => context.Errors.Count.Should().Be(1)); }
public void ParseIsSkippedIfModelIsMissing(BizTalkApplicationParser 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 BizTalkApplicationParser(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 BizTalkApplicationParser(model, context, logger))); "Then the parser constructor should succeed" .x(() => { e.Should().BeNull(); parser.Should().NotBeNull(); }); }