Ejemplo n.º 1
0
        public void ConstructWithNullFileRepository(SC001DocumentSchemaGenerator generator, IFileRepository fileRepository, ILogger logger, IApplicationModel model, MigrationContext context, Exception e)
        {
            "Given an generator"
            .x(() => generator.Should().BeNull());

            "And a null file repository"
            .x(() => fileRepository.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 with a null file repository"
            .x(() => e = Record.Exception(() => new SC001DocumentSchemaGenerator(fileRepository, model, context, logger)));

            "Then the constructor should throw an exception"
            .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("fileRepository"));
        }
Ejemplo n.º 2
0
        public void ConstructWithSuccess(SC001DocumentSchemaGenerator generator, IFileRepository fileRepository, ILogger logger, IApplicationModel model, MigrationContext context, Exception e)
        {
            "Given an generator"
            .x(() => generator.Should().BeNull());

            "And a file repository"
            .x(() => fileRepository = _mockFileRepository.Object);

            "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 SC001DocumentSchemaGenerator(fileRepository, model, context, logger)));

            "Then the constructor should NOT throw an exception"
            .x(() => e.Should().BeNull());
        }
Ejemplo n.º 3
0
        public void GenerateXmlSchema(SC001DocumentSchemaGenerator generator, IFileRepository fileRepository, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given an generator"
            .x(() => generator.Should().BeNull());

            "And a file repository"
            .x(() => fileRepository = _mockFileRepository.Object);

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

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

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

            "And an generator"
            .x(() => generator = new SC001DocumentSchemaGenerator(fileRepository, model, context, logger));

            "When generating"
            .x(async() => e = await Record.ExceptionAsync(async() => await generator.ConvertAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

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

            "And 1 schema has been created"
            .x(() =>
            {
                model.Should().NotBeNull();

                _mockFileRepository.Verify(r => r.WriteXmlFile(
                                               It.IsAny <string>(),
                                               It.IsAny <string>()),
                                           Times.Once);
            });
        }