protected override void Act() { // simulate writing the data twice _templateWriter.WriteAsync(_templateWriterData, CancellationToken.None) .RunSynchronously(); _templateWriter.WriteAsync(_templateWriterData, CancellationToken.None) .RunSynchronously(); }
public async Task ProcessAsync(AssemblyData assemblyData, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); _logger.Info($"Processing started for assembly: {assemblyData.AssemblyName} in folder: {assemblyData.Path}"); var stopWatch = new Stopwatch(); stopWatch.Start(); var templateContext = _templateContextProvider.Create(assemblyData); foreach (var templateSet in _templateSetProvider.GetTemplatesByName(assemblyData.TemplateSet)) { templateContext.With(templateSet); _logger.Debug($"Generating code for template {templateSet.Name}"); var generator = _generatorProvider.GetGeneratorByDriverName(templateSet.Driver); if (generator != null) { var templateStopwatch = new Stopwatch(); templateStopwatch.Start(); var model = generator.Generate(templateContext); _logger.Debug($"Generating template data for template {templateSet.Name}"); string outputPath = Path.Combine(assemblyData.Path, templateSet.OutputPath); var codeGenWriterData = new TemplateWriterData { TemplateSet = templateSet, Model = model, OutputPath = outputPath }; _logger.Debug($"Writing template data for path {outputPath}"); await _templateWriter.WriteAsync(codeGenWriterData, cancellationToken) .ConfigureAwait(false); templateStopwatch.Stop(); _logger.Debug( $"Code generation for template {templateSet.Name} completed in {templateStopwatch.Elapsed.ToString()}."); } else { _logger.Debug($"TemplateSet model not found for {templateSet.Name}, skipping."); } } stopWatch.Stop(); _logger.Info($"Processing complete for assembly: {assemblyData.AssemblyName} in {stopWatch.Elapsed.ToString()}."); }
public void Should_call_templateWriter_WriteAsync_once() => A.CallTo(() => _templateWriter.WriteAsync(A <TemplateWriterData> .That.IsNotNull(), CancellationToken.None)) .MustHaveHappenedOnceExactly();