예제 #1
0
        public void ConstructWithNullFileRepository(MA001TransformGenerator 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 MA001TransformGenerator(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"));
        }
예제 #2
0
        public void ConstructWithSuccess(MA001TransformGenerator 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 MA001TransformGenerator(fileRepository, model, context, logger)));

            "Then the constructor should NOT throw an exception"
            .x(() => e.Should().BeNull());
        }
예제 #3
0
        public void GenerateMapper(MA001TransformGenerator 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 MA001TransformGenerator(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);
            });
        }