public void ParseIsSkippedIfModelIsMissing(OrchestrationPortTypeParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { "Given a model" .x(() => { model = new AzureIntegrationServicesModel(); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new OrchestrationPortTypeParser(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 = new Mock <ILogger>().Object); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = new MigrationContext()); "When constructing" .x(() => e = Record.Exception(() => parser = new OrchestrationPortTypeParser(model, context, logger))); "Then the parser constructor should succeed" .x(() => { e.Should().BeNull(); parser.Should().NotBeNull(); }); }
public void ParsePortTypeWithMissingModule(OrchestrationPortTypeParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { var orchestrationDefinitionName = "orchestrationDefinitionName"; var orchestrationDefinitionKey = "orchestrationDefinitionKey"; var asmContainerKey = "asmContainerKey"; var wrongKey = "wrongKey"; "Given a source model with an orchestration with a missing module" .x(() => { var orchestration = new Orchestration { Name = orchestrationDefinitionName, ResourceContainerKey = asmContainerKey, ResourceDefinitionKey = wrongKey }; var parsedApplication = new ParsedBizTalkApplication { Application = new BizTalkApplication() }; parsedApplication.Application.Orchestrations.Add(orchestration); model = new AzureIntegrationServicesModel(); var group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; group.Applications.Add(parsedApplication); }); "And one orchestration in the source report model" .x(() => { var msiContainer = new ResourceContainer() { Key = "TestMsi.Key", Name = "TestMsi", Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi" }; model.MigrationSource.ResourceContainers.Add(msiContainer); var cabContainer = new ResourceContainer() { Key = "TestCab.Key", Name = "TestCab", Type = ModelConstants.ResourceContainerCab, ContainerLocation = @"C:\Test\Test.CAB" }; msiContainer.ResourceContainers.Add(cabContainer); var asmContainer = new ResourceContainer() { Key = asmContainerKey, Name = "TestAssembly", Type = ModelConstants.ResourceContainerAssembly, ContainerLocation = @"C:\Test\Test.dll" }; cabContainer.ResourceContainers.Add(asmContainer); var orchestrationDefinition = new ResourceDefinition() { Key = orchestrationDefinitionKey, Name = orchestrationDefinitionName, Type = ModelConstants.ResourceDefinitionOrchestration }; asmContainer.ResourceDefinitions.Add(orchestrationDefinition); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new OrchestrationPortTypeParser(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 an error logged" .x(() => { context.Errors.Should().NotBeNull(); context.Errors.Should().HaveCount(1); context.Errors[0].Message.Should().Contain(wrongKey); context.Errors[0].Message.Should().Contain(ModelConstants.ResourceModule); }); }
public void ParsePortTypeWithSuccess(OrchestrationPortTypeParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { var orchestrationDefinitionName = "orchestrationDefinitionName"; var orchestrationDefinitionKey = "orchestrationDefinitionKey"; var portTypeName = "portTypeName"; var asmContainerKey = "asmContainerKey"; "Given a source model with an orchestration and a port type" .x(() => { var odxModel = new MetaModel { Element = new Element[] { new Element { Type = "Module", Element1 = new Element[] { new Element { Type = "PortType", Property = new ElementProperty[] { new ElementProperty { Name = "Name", Value = portTypeName } } } } } } }; var orchestration = new Orchestration { Name = orchestrationDefinitionName, ResourceContainerKey = asmContainerKey, ResourceDefinitionKey = orchestrationDefinitionKey, Model = odxModel }; var parsedApplication = new ParsedBizTalkApplication { Application = new BizTalkApplication() }; parsedApplication.Application.Orchestrations.Add(orchestration); model = new AzureIntegrationServicesModel(); var group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; group.Applications.Add(parsedApplication); }); "And one orchestration in the source report model" .x(() => { var msiContainer = new ResourceContainer() { Key = "TestMsi.Key", Name = "TestMsi", Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi" }; model.MigrationSource.ResourceContainers.Add(msiContainer); var cabContainer = new ResourceContainer() { Key = "TestCab.Key", Name = "TestCab", Type = ModelConstants.ResourceContainerCab, ContainerLocation = @"C:\Test\Test.CAB" }; msiContainer.ResourceContainers.Add(cabContainer); var asmContainer = new ResourceContainer() { Key = asmContainerKey, Name = "TestAssembly", Type = ModelConstants.ResourceContainerAssembly, ContainerLocation = @"C:\Test\Test.dll" }; cabContainer.ResourceContainers.Add(asmContainer); var orchestrationDefinition = new ResourceDefinition() { Key = orchestrationDefinitionKey, Name = orchestrationDefinitionName, Type = ModelConstants.ResourceDefinitionOrchestration }; asmContainer.ResourceDefinitions.Add(orchestrationDefinition); var metaModel = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Orchestrations[0].Model; var metaModelResource = new ResourceItem() { Key = string.Concat(orchestrationDefinitionKey, ":", MetaModelConstants.MetaModelRootElement), Name = MetaModelConstants.MetaModelRootElement, Type = ModelConstants.ResourceMetaModel }; metaModel.Resource = metaModelResource; metaModelResource.SourceObject = metaModel; orchestrationDefinition.Resources.Add(metaModelResource); var moduleResource = new ResourceItem() { Key = string.Concat(metaModelResource.Key, ":", MetaModelConstants.ElementTypeModule), Name = MetaModelConstants.ElementTypeModule, Type = ModelConstants.ResourceModule }; metaModelResource.Resources.Add(moduleResource); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new OrchestrationPortTypeParser(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 logged" .x(() => context.Errors.Should().BeNullOrEmpty()); "And the resources should be set." .x(() => { // Check the port type resource has been created. var moduleResource = model.FindResourcesByType(ModelConstants.ResourceModule).SingleOrDefault(); moduleResource.Should().NotBeNull(); var portTypeResource = model.FindResourcesByType(ModelConstants.ResourcePortType).SingleOrDefault(); portTypeResource.Should().NotBeNull(); var portType = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Orchestrations[0].FindPortTypes().Single(); // Validate the port type resource. portTypeResource.Should().NotBeNull(); portTypeResource.Key.Should().Be(string.Concat(moduleResource.Key, ":", portTypeName)); portTypeResource.Name.Should().Be(portTypeName); portTypeResource.Type.Should().Be(ModelConstants.ResourcePortType); portType.Resource.Should().Be(portTypeResource); // The pointer to the resource should be set. portTypeResource.ParentRefId.Should().Be(moduleResource.RefId); // The parent ref ID should be set. portTypeResource.SourceObject.Should().Be(portType); // The resource should have a pointer to the source object. }); }