private static IEnumerable <string> GetGeneratedFilesPaths(string targetDirectoryPath, TestsGeneratorRestrictions restrictions, IEnumerable <string> filePaths) { List <ConsumerResult <string> > generatedFilePaths = new List <ConsumerResult <string> >(); try { var fileSourceCodeProvider = new FileSourceCodeProvider(filePaths); var fileConsumer = new FileConsumer(targetDirectoryPath); var testsGenerator = new TestsGenerator(restrictions); generatedFilePaths = testsGenerator.Generate(fileSourceCodeProvider, fileConsumer).ToList(); } catch (AggregateException aggregateException) { Console.WriteLine(ErrorPromt); foreach (Exception exception in aggregateException.InnerExceptions) { Console.WriteLine(exception.Message); } } catch (ArgumentOutOfRangeException argOutOfRangeException) { Console.WriteLine(ErrorPromt); Console.WriteLine(argOutOfRangeException.Message); } return(generatedFilePaths.Select(x => x.Result).Cast <string>()); }
public void SetUp() { _fullPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var fileSourceCodeProvider = new FileSourceCodeProvider(new List <string> { _fullPath + @"\TracerUse.csnotcompilable" }); var fileConsumer = new FileConsumer(_fullPath + @"\GeneratedTests\"); _testsGenerator = new TestsGenerator(); _testsGenerator.Generate(fileSourceCodeProvider, fileConsumer); string generatedTestText = File.ReadAllText(_fullPath + @"\GeneratedTests\TracerUseTests.cs"); SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(generatedTestText); _testCompilationUnit = syntaxTree.GetCompilationUnitRoot(); }
private static void GenerateTestsAndWriteToConsole(TestsGeneratorRestrictions restrictions, IEnumerable <string> filePaths) { try { var fileSourceCodeProvider = new FileSourceCodeProvider(filePaths); var consoleConsumer = new ConsoleConsumer(); var testsGenerator = new TestsGenerator(restrictions); testsGenerator.Generate(fileSourceCodeProvider, consoleConsumer); } catch (AggregateException aggregateException) { Console.WriteLine(ErrorPromt); foreach (Exception exception in aggregateException.InnerExceptions) { Console.WriteLine(exception.Message); } } catch (ArgumentOutOfRangeException argOutOfRangeException) { Console.WriteLine(ErrorPromt); Console.WriteLine(argOutOfRangeException.Message); } }