public void DP006RuleSkippedIfModelIsEmpty(DP006ParentChildDependencyAnalyzer 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 DP006ParentChildDependencyAnalyzer(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 DP006ResolveDependenciesWithSuccess(DP006ParentChildDependencyAnalyzer 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 DP006ParentChildDependencyAnalyzer(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 resources
                var resources = model.FindAllResources();

                var receivePort = resources.Where(r => r.Type == ModelConstants.ResourceReceivePort).First();
                receivePort.Should().NotBeNull();

                var receiveLocation = resources.Where(r => r.Type == ModelConstants.ResourceReceiveLocation).First();
                receiveLocation.Should().NotBeNull();

                // Check that the receive port has a parent-child to receive location
                receivePort.ResourceRelationships.Count.Should().Be(1);
                receivePort.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.Child);
                receivePort.ResourceRelationships[0].ResourceRefId.Should().Be(receiveLocation.RefId);

                // Check that the receive location has a child-parent to receive port
                receiveLocation.ResourceRelationships.Count.Should().Be(1);
                receiveLocation.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.Parent);
                receiveLocation.ResourceRelationships[0].ResourceRefId.Should().Be(receivePort.RefId);
            });
        }
        public void ConstructWithNullContext(DP006ParentChildDependencyAnalyzer 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 DP006ParentChildDependencyAnalyzer(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(DP006ParentChildDependencyAnalyzer 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 DP006ParentChildDependencyAnalyzer(model, context, logger)));

            "Then the constructor should NOT throw an exception"
            .x(() => e.Should().BeNull());
        }