public void DP005RuleSkippedIfModelIsEmpty(DP005DistributionListDependencyAnalyzer 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 DP005DistributionListDependencyAnalyzer(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 the logger should have been called once" .x(() => _mockLogger.Invocations.Count.Should().Be(2)); }
public void DP005ResolveDistributionListDependenciesMultipleMatches(DP005DistributionListDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForAnalyzing(); var sendPort = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceSendPort).Single(); model.MigrationSource.ResourceContainers[0].ResourceDefinitions[7].Resources.Add(new ResourceItem() { Type = ModelConstants.ResourceSendPort, ParentRefId = sendPort.ParentRefId, SourceObject = sendPort.SourceObject, Name = sendPort.Name }); }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP005DistributionListDependencyAnalyzer(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 resources should have the expected relationships created" .x(() => { var distributionList = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceDistributionList).Single(); var sendPort = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceSendPort).First(); // Check that the DL has the correct info distributionList.ResourceRelationships.Count.Should().Be(0); distributionList.ReportMessages.Count.Should().Be(1); distributionList.ReportMessages[0].Severity.Should().Be(MessageSeverity.Warning); distributionList.ReportMessages[0].Message.Should().Contain("Dependency cannot be accurately resolved."); // Check that the SP has the correct info sendPort.ResourceRelationships.Count.Should().Be(0); sendPort.ReportMessages.Count.Should().Be(0); }); }
public void DP005ResolveDistributionListDependenciesWithSuccess(DP005DistributionListDependencyAnalyzer 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 DP005DistributionListDependencyAnalyzer(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 resources should have the expected relationships created" .x(() => { // Test the applications var applications = model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications; applications.Should().NotBeNull().And.HaveCount(3); var distributionList = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceDistributionList).Single(); var sendPort = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceSendPort).Single(); // Check that the DL has a relationship to the send port distributionList.ResourceRelationships.Count.Should().Be(1); distributionList.ResourceRelationships[0].ResourceRefId.Should().Be(sendPort.RefId); distributionList.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.CallsTo); // Check that the SP has a relationship to the DL sendPort.ResourceRelationships.Count.Should().Be(1); sendPort.ResourceRelationships[0].ResourceRefId.Should().Be(distributionList.RefId); sendPort.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.CalledBy); }); }
public void DP005ResolveDistributionListDependenciesNullSourceObject(DP005DistributionListDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e) { "Given a source model" .x(() => { model = TestHelper.CreateDefaultModelForAnalyzing(); // Null the source object to make the resource unfindable model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceDistributionList).Single().SourceObject = null; }); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "And an analyzer" .x(() => analyzer = new DP005DistributionListDependencyAnalyzer(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 resources should have the expected relationships created" .x(() => { var distributionList = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceDistributionList).Single(); var sendPort = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceSendPort).Single(); // Check that the DL has the correct info distributionList.ResourceRelationships.Count.Should().Be(0); distributionList.ReportMessages.Count.Should().Be(1); distributionList.ReportMessages[0].Severity.Should().Be(MessageSeverity.Error); // Check that the SP has the correct info sendPort.ResourceRelationships.Count.Should().Be(0); sendPort.ReportMessages.Count.Should().Be(0); }); }
public void ConstructWithNullContext(DP005DistributionListDependencyAnalyzer 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 DP005DistributionListDependencyAnalyzer(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(DP005DistributionListDependencyAnalyzer 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 DP005DistributionListDependencyAnalyzer(model, context, logger))); "Then the constructor should NOT throw an exception" .x(() => e.Should().BeNull()); }