static int Main(string[] args) { if (args.Length < MinParametersCount) { Console.WriteLine(UsageInfo); Console.ReadKey(); return(1); } List <string> filePaths = new List <string>(); string targetDirectoryPath = args.ElementAt(args.Length - 3); int maxCountTasksToProcess = int.Parse(args.ElementAt(args.Length - 2)); int maxCountTasksToWrite = int.Parse(args.ElementAt(args.Length - 1)); var restrictions = new TestsGeneratorRestrictions(maxCountTasksToProcess, maxCountTasksToWrite); for (int i = 0; i < args.Length - 3; ++i) { filePaths.Add(args[i]); } IEnumerable <string> generatedFilePaths = GetGeneratedFilesPaths(targetDirectoryPath, restrictions, filePaths).ToList(); WriteResults(generatedFilePaths); GenerateTestsAndWriteToConsole(restrictions, filePaths); Console.ReadKey(); return(0); }
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); } }
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>()); }