public void DP001ResolveContextPropertyDependenciesWithSuccess(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForAnalyzing(); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP001SchemaDependencyAnalyzer(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 report node should have the correct resources created" .x(() => { var group = (ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel; // Test the document schema var dsResource = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document).First().Resource; dsResource.ResourceRelationships.Count.Should().Be(3); dsResource.ResourceRelationships[1].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencesTo); dsResource.ResourceRelationships[2].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencesTo); // Test the property schema var psResource = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Property).First().Resource; psResource.ResourceRelationships.Count.Should().Be(1); psResource.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencedBy); // Test the first context property - this should be referenced var cpResource1 = psResource.Resources.Where(r => r.Key == "property-schema-1:schema:Property1").First(); cpResource1.ResourceRelationships.Count.Should().Be(1); cpResource1.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencedBy); // Test the first context property - this should NOT be referenced var cpResource2 = psResource.Resources.Where(r => r.Key == "property-schema-1:schema:Property2").First(); cpResource2.ResourceRelationships.Count.Should().Be(0); }); }
public void DP001ResolveContextPropertyDependenciesWithWarnings(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForAnalyzing(); var schemas = model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications.SelectMany(a => a.Application.Schemas); foreach (var schema in schemas) { if (schema.SchemaType == Types.Enumerations.BizTalkSchemaType.Property) { schema.ContextProperties.Clear(); } } }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP001SchemaDependencyAnalyzer(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 report resource node should have warnings" .x(() => { // Check the application resource has been created. var group = (ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel; var schemas = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document).ToList(); schemas.Should().HaveCount(3); schemas[0].Resource.ReportMessages.Should().HaveCountGreaterThan(0); schemas[1].Resource.ReportMessages.Should().HaveCount(0); }); }
public void ConstructWithNullContext(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And null context" .x(() => context.Should().BeNull()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing with a null context" .x(() => e = Record.Exception(() => new DP001SchemaDependencyAnalyzer(model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("context")); }
public void ConstructWithSuccess(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, IApplicationModel model, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing" .x(() => e = Record.Exception(() => new DP001SchemaDependencyAnalyzer(model, context, logger))); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); }
public void DP001RuleSkippedIfModelIsEmpty(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given an source model" .x(() => model = new AzureIntegrationServicesModel()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP001SchemaDependencyAnalyzer(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)); }