コード例 #1
0
        public void ExceptionThrowingTest()
        {
            TestsGeneratorConfig config = new TestsGeneratorConfig
            {
                ReadPaths = new List <string>
                {
                    "NonExistingFile.cs"
                }
            };

            Assert.ThrowsException <AggregateException>(() => new TestsGenerator(config).Generate().Wait());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            int           readingLimit    = 3;
            int           writingLimit    = 3;
            int           processingLimit = 8;
            string        workPath        = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName + "\\TestsFilesForTesting\\";
            List <string> pathes          = new List <string>();

            pathes.Add(workPath + "BaseGenerator.cs");
            pathes.Add(workPath + "TestsGenerator.cs");

            TestsGeneratorConfig config    = new TestsGeneratorConfig(readingLimit, processingLimit, writingLimit);
            TestsGenerator       generator = new TestsGenerator(config);

            generator.Generate(pathes, workPath + "GeneratedTests").Wait();
            Console.WriteLine("Complete");
        }
コード例 #3
0
        public void SetUp()
        {
            int                  readingLimit = 3, writingLimit = 3, processingLimit = 8;
            string               sourceCode;
            string               workPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName + "\\TestsFilesForTesting\\";
            SyntaxTree           codeTree;
            List <string>        pathes = new List <string>();
            TestsGeneratorConfig config;
            TestsGenerator       generator;

            pathes.Add(workPath + "TestsGenerator.cs");
            config    = new TestsGeneratorConfig(readingLimit, processingLimit, writingLimit);
            generator = new TestsGenerator(config);
            generator.Generate(pathes, workPath + "GeneratedTests").Wait();

            sourceCode = File.ReadAllText(workPath + "GeneratedTests\\TestsGeneratorTest.dat");
            codeTree   = CSharpSyntaxTree.ParseText(sourceCode);
            _root      = codeTree.GetCompilationUnitRoot();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            TestsGeneratorConfig config = new TestsGeneratorConfig
            {
                ReadPaths = new List <string>
                {
                    "../../SimpleTestFile.cs",
                    "../../ExtendedTestFile.cs"
                },
                Writer = new AsyncFileWriter()
                {
                    Directory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                },
                ReadThreadCount  = 2,
                WriteThreadCount = 2
            };

            new TestsGenerator(config).Generate().Wait();
            Console.WriteLine("Generation completed");
            Console.ReadKey();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            /*Console.WriteLine("Write list of test separating them by spaces");
             * var testFiles = Console.ReadLine().Split(' ').ToList();
             * Console.WriteLine("Write max amount of streams for reading");
             * var maxInputStreams = int.Parse(Console.ReadLine());
             * Console.WriteLine("Write max amount of streams for writing");
             * var maxOutStreams = int.Parse(Console.ReadLine());
             * Console.WriteLine("Write max amount of streams for generating tests");
             * var maxMainStreams = int.Parse(Console.ReadLine());*/
            TestsGeneratorConfig config = new TestsGeneratorConfig
            {
                ReadPaths = new List <string>
                {
                    "../../SimpleTestFile.cs",
                    "../../ExtendedTestFile.cs"
                },
                Writer = new AsyncFileWriter()
                {
                    Directory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                },
                ReadThreadCount    = 2,
                WriteThreadCount   = 2,
                processThreadCount = 2

                                     /*ReadPaths=testFiles,
                                      * Writer = new AsyncFileWriter()
                                      * {
                                      *  Directory = "../../GeneratedTests"
                                      * },
                                      * ReadThreadCount = maxInputStreams,
                                      * WriteThreadCount = maxOutStreams,
                                      * processThreadCount = maxMainStreams*/
            };

            new TestsGenerator(config).Generate().Wait();
            Console.WriteLine("Generation completed");
            Console.ReadKey();
        }
コード例 #6
0
        public void TestInit()
        {
            string testFilesDirectory = "../../";
            string testFilePath       = testFilesDirectory + "TestFile.cs";
            string testClass1FilePath = testFilesDirectory + "TestClass1Test.cs";
            string testClass2FilePath = testFilesDirectory + "TestClass2Test.cs";

            TestsGeneratorConfig config = new TestsGeneratorConfig
            {
                ReadPaths = new List <string>
                {
                    testFilePath
                },
                Writer = new AsyncFileWriter()
                {
                    Directory = testFilesDirectory
                }
            };

            new TestsGenerator(config).Generate().Wait();

            class1Root = CSharpSyntaxTree.ParseText(File.ReadAllText(testClass1FilePath)).GetCompilationUnitRoot();
            class2Root = CSharpSyntaxTree.ParseText(File.ReadAllText(testClass2FilePath)).GetCompilationUnitRoot();
        }