public void ConstructWithNullModel(HtmlReportFormatter reporter, IApplicationModel model, MigrationContext context, IRunState state, IReportWriter writer, ILogger logger, Exception e)
        {
            "Given an reporter"
            .x(() => reporter.Should().BeNull());

            "And a model"
            .x(() => model.Should().BeNull());

            "And run state"
            .x(() => state = TestHelper.BuildRunState(model));

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a writer"
            .x(() => writer = _mockWriter.Object);

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "When constructing with a null model"
            .x(() => e = Record.Exception(() => new HtmlReportFormatter(model, context, state, writer, logger)));

            "Then the constructor should throw an exception"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("model"));
        }
        public void ConstructWithSuccess(HtmlReportFormatter reporter, IApplicationModel model, MigrationContext context, IRunState state, IReportWriter writer, ILogger logger, Exception e)
        {
            "Given an reporter"
            .x(() => reporter.Should().BeNull());

            "And a model"
            .x(() => model = TestHelper.BuildModel());

            "And run state"
            .x(() => state = TestHelper.BuildRunState(model));

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a writer"
            .x(() => writer = _mockWriter.Object);

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "When constructing..."
            .x(() => e = Record.Exception(() => new HtmlReportFormatter(model, context, state, writer, logger)));

            "Then the constructor should NOT throw an exception"
            .x(() => e.Should().BeNull());
        }
        public void ReportHtmlGenerationNoApplication(HtmlReportFormatter reporter, AzureIntegrationServicesModel model, MigrationContext context, IRunState state, IReportWriter writer, ILogger logger, Exception e)
        {
            "Given a model"
            .x(() => {
                model = TestHelper.BuildModel();
                model.MigrationSource.ResourceContainers.ToList().ForEach(rc =>
                {
                    rc.ResourceContainers.Clear();
                    rc.ResourceDefinitions.Clear();
                });     //removes any resource containers.
            });

            "And run state"
            .x(() => state = TestHelper.BuildRunState(model));

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a writer"
            .x(() => writer = _mockWriter.Object);

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an reporter"
            .x(() => reporter = new HtmlReportFormatter(model, context, state, writer, logger));

            "When executing the report formatter"
            .x(() => e = Record.Exception(() => reporter.Report()));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "The report node should have a source application"
            .x(() =>
            {
                _mockWriter.Invocations.Count.Should().Be(4);
                _mockWriter.Invocations[0].Arguments.Count.Should().Be(2);
                _mockWriter.Invocations[0].Arguments[0].Should().Be(context.ReportFilePath);
                _mockWriter.Invocations[0].Arguments[1].Should().NotBeNull();

                var invocation = _mockLogger.Invocations.Where(i => i.Arguments[0].ToString() == "Warning").FirstOrDefault();
                invocation.Should().NotBeNull();
                invocation.Arguments[2].ToString().Should().Contain("no reportable BizTalk application");
            });
        }
        public void ReportHtmlGenerationNoContainers(HtmlReportFormatter reporter, AzureIntegrationServicesModel model, MigrationContext context, IRunState state, IReportWriter writer, ILogger logger, Exception e)
        {
            "Given a model"
            .x(() => {
                model = TestHelper.BuildModel();
                model.MigrationSource.ResourceContainers.Clear();     //removes any resource containers.
            });

            "And run state"
            .x(() => state = TestHelper.BuildRunState(model));

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a writer"
            .x(() => writer = _mockWriter.Object);

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an reporter"
            .x(() => reporter = new HtmlReportFormatter(model, context, state, writer, logger));

            "When executing the report formatter"
            .x(() => e = Record.Exception(() => reporter.Report()));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "The report node should have a source application"
            .x(() =>
            {
                _mockWriter.Invocations.Count.Should().Be(4);
                _mockWriter.Invocations[0].Arguments.Count.Should().Be(2);
                _mockWriter.Invocations[0].Arguments[0].Should().Be(context.ReportFilePath);
                _mockWriter.Invocations[0].Arguments[1].Should().NotBeNull();

                var html = (string)_mockWriter.Invocations[0].Arguments[1];
                html.Should().Contain("No Input BizTalk Applications");
            });
        }
        public void ReportHtmlGenerationHappyPath(HtmlReportFormatter reporter, AzureIntegrationServicesModel model, MigrationContext context, IRunState state, IReportWriter writer, ILogger logger, Exception e)
        {
            "Given a model"
            .x(() => model = TestHelper.BuildModel());

            "And run state"
            .x(() => state = TestHelper.BuildRunState(model));

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a writer"
            .x(() => writer = _mockWriter.Object);

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an reporter"
            .x(() => reporter = new HtmlReportFormatter(model, context, state, writer, logger));

            "When executing the report formatter"
            .x(() => e = Record.Exception(() => reporter.Report()));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "The report node should have a source application"
            .x(() =>
            {
                _mockWriter.Invocations.Count.Should().Be(5);
                _mockWriter.Invocations[0].Arguments.Count.Should().Be(2);
                _mockWriter.Invocations[0].Arguments[0].Should().Be(context.ReportFilePath);
                _mockWriter.Invocations[0].Arguments[1].Should().NotBeNull();
                _mockWriter.Invocations[0].Arguments[1].Should().NotBeEquivalentTo(string.Empty);
            });
        }