public void ConstructWithNullFileRepository(TemplateRendererConverter converter, IFileRepository fileRepository, ITemplateRepository repository, ITemplateRenderer renderer, IApplicationModel model, ILogger logger, MigrationContext context, Exception e) { "Given a converter" .x(() => converter.Should().BeNull()); "And a null file repository" .x(() => fileRepository.Should().BeNull()); "And a repository" .x(() => repository = _mockRepository.Object); "And a renderer" .x(() => renderer = _mockRenderer.Object); "And a model" .x(() => model = TestHelper.CreateDefaultModelForConverting()); "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 TemplateRendererConverter(fileRepository, repository, renderer, model, context, logger))); "Then the constructor should throw an exception" .x(() => e.Should().NotBeNull().And.Subject.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("fileRepository")); }
public void ConvertAsyncWithSuccess(TemplateRendererConverter converter, IApplicationModel model, MigrationContext context, Exception e) { "Given a model" .x(() => model = TestHelper.CreateDefaultModelForConverting()); "And a context" .x(() => context = TestHelper.BuildContext()); "And a converter" .x(() => converter = new TemplateRendererConverter(_mockFileRepository.Object, _mockRepository.Object, _mockRenderer.Object, model, context, _mockLogger.Object)); "When converting" .x(async() => e = await Record.ExceptionAsync(async() => await converter.ConvertAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false)); "Then the convert should succeed" .x(() => e.Should().BeNull()); "And the resource template files should have been generated using the renderer and repository" .x(() => { _mockRepository.Verify(r => r.LoadTemplateAsync( It.IsAny <string>()), Times.Once); _mockRenderer.Verify(r => r.RenderTemplateAsync( It.IsAny <string>(), It.Is <AzureIntegrationServicesModel>(m => m == model), It.IsAny <MessagingObject>(), It.IsAny <TargetResourceTemplate>()), Times.Once); _mockRepository.Verify(r => r.SaveTemplateAsync( It.IsAny <string>(), It.IsAny <string>()), Times.Once); _mockFileRepository.Verify(r => r.CopyFile( It.IsAny <string>(), It.IsAny <string>()), Times.Once); }); }