public void AnalyzeAsyncWithSuccess(ResourceGeneratorAnalyzer analyzer, IApplicationModel model, MigrationContext context, Exception e) { "Given a model" .x(() => model = TestHelper.CreateDefaultModelForAnalyzing()); "And a context" .x(() => context = TestHelper.BuildContext()); "And an analyzer" .x(() => analyzer = new ResourceGeneratorAnalyzer(_mockRepository.Object, _mockGenerator.Object, model, context, _mockLogger.Object)); "When analyzing" .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then the analyze should succeed" .x(() => e.Should().BeNull()); "And the model target resource templates should have been generated using the generator" .x(() => { _mockGenerator.Verify(g => g.GenerateResourcesAsync( It.Is <AzureIntegrationServicesModel>(m => m == model), It.IsAny <IList <YamlStream> >(), It.Is <CancellationToken>(t => t == CancellationToken.None)), Times.Once); }); }
public void ConstructWithNullRepository(ResourceGeneratorAnalyzer analyzer, IConfigurationRepository repository, IResourceGenerator generator, IApplicationModel model, ILogger logger, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a null repository" .x(() => repository.Should().BeNull()); "And a generator" .x(() => generator = _mockGenerator.Object); "And a model" .x(() => model = TestHelper.CreateDefaultModelForAnalyzing()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing with a null repository" .x(() => e = Record.Exception(() => new ResourceGeneratorAnalyzer(repository, generator, model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("repository")); }
public void ConstructWithSuccess(ResourceGeneratorAnalyzer analyzer, IConfigurationRepository repository, IResourceGenerator generator, IApplicationModel model, ILogger logger, MigrationContext context, Exception e) { "Given an analyzer" .x(() => analyzer.Should().BeNull()); "And a repository" .x(() => repository = _mockRepository.Object); "And a generator" .x(() => generator = _mockGenerator.Object); "And a model" .x(() => model = TestHelper.CreateDefaultModelForAnalyzing()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a logger" .x(() => logger = _mockLogger.Object); "When constructing" .x(() => e = Record.Exception(() => new ResourceGeneratorAnalyzer(repository, generator, model, context, logger))); "Then the constructor should succeed" .x(() => e.Should().BeNull()); }