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 CheckFileCount()
        {
            var actual   = TestsGenerator.GenerateTests(sourceCode).Length;
            var expected = 2;

            Assert.That(actual, Is.EqualTo(expected));
        }
        public void CheckMethodsGeneration()
        {
            TestUnit[] actualUnits = TestsGenerator.GenerateTests(sourceCode);

            int[] actual1 = CSharpSyntaxTree.ParseText(actualUnits[0].sourceCode).
                            GetRoot().
                            DescendantNodes().OfType <MethodDeclarationSyntax>().
                            Select(m => m.Body.Statements.Count).
                            ToArray();
            int[] actual2 = CSharpSyntaxTree.ParseText(actualUnits[1].sourceCode).
                            GetRoot().
                            DescendantNodes().OfType <MethodDeclarationSyntax>().
                            Select(m => m.Body.Statements.Count).
                            ToArray();

            int[] expected1 = { 4, 2, 5 };
            int[] expected2 = { 1, 4, 4 };

            Assert.AreEqual(expected1[0], actual1[0]);
            Assert.AreEqual(expected1[1], actual1[1]);
            Assert.AreEqual(expected1[2], actual1[2]);

            Assert.AreEqual(expected2[0], actual2[0]);
            Assert.AreEqual(expected2[1], actual2[1]);
            Assert.AreEqual(expected2[2], actual2[2]);
        }
 public GenerateLayer(int maxThreadsCount, CommunicationSet <FileSource> inputSet, CommunicationSet <FileSource> outputSet)
 {
     maxCount       = maxThreadsCount;
     this.outputSet = outputSet;
     this.inputSet  = inputSet;
     generator      = new TestsGenerator();
 }
        public void SetUp()
        {
            _readingTasksCount = 3;
            _writingTasksCount = 3;
            _config            = new TestGeneratorConfig(_readingTasksCount, _writingTasksCount);

            _outputDirectory = "./";

            _paths = new List <string>();
            _paths.Add("./AnotherClass.csSource");
            _paths.Add("./SomeClass.csSource");

            _reader = new CodeReader();
            _writer = new CodeWriter(_outputDirectory);

            _generator = new TestsGenerator(_config);
            _generator.Generate(_reader, _writer, _paths).Wait();

            _programmText = File.ReadAllText("./SomeClassTests.cs");
            SyntaxTree syntaxTree;

            syntaxTree = CSharpSyntaxTree.ParseText(_programmText);

            _compilationUnitSyntax = syntaxTree.GetCompilationUnitRoot();
        }
Example #6
0
        public Task Generate(List <string> inputFiles, string outputPath, int maxReadText, int maxGenerateTest, int maxWriteText)
        {
            var ExecReaxOption = new ExecutionDataflowBlockOptions();

            ExecReaxOption.MaxDegreeOfParallelism = maxReadText;

            var ExecGenerateOption = new ExecutionDataflowBlockOptions();

            ExecGenerateOption.MaxDegreeOfParallelism = maxGenerateTest;
            var ExecWriteOption = new ExecutionDataflowBlockOptions();

            ExecWriteOption.MaxDegreeOfParallelism = maxWriteText;

            var readText      = new TransformBlock <string, string>(async textReadPath => await ReadTextAsync(textReadPath), ExecReaxOption);
            var generateTests = new TransformManyBlock <string, Tests>(textCode => TestsGenerator.GenerateTests(textCode), ExecGenerateOption);
            var writeText     = new ActionBlock <Tests>(async test => await WriteTextAsync(Path.Combine(outputPath, test.FileName), test.TestCode), ExecWriteOption);


            var linkOptions = new DataflowLinkOptions();

            linkOptions.PropagateCompletion = true;

            readText.LinkTo(generateTests, linkOptions);
            generateTests.LinkTo(writeText, linkOptions);


            foreach (string file in inputFiles)
            {
                readText.Post(file);
            }

            readText.Complete();

            return(writeText.Completion);
        }
Example #7
0
        public void TestAbstactClass()
        {
            string AbstactClassTest = @"namespace AbsractName
                                            {
                                                abstract class Person
                                                {
                                                    public string Name { get; set; }

                                                    public Person(string name)
                                                    {
                                                        Name = name;
                                                    }

                                                    public void Display()
                                                    {
                                                        Console.WriteLine(Name);
                                                    }
                                                }

                                            }";

            Tests[] tests = TestsGenerator.GenerateTests(AbstactClassTest);

            Assert.AreEqual(tests.Length, 0);
        }
        public Task Generate(int maxDegreeOfParallelism, string resultPath, params string[] files)
        {
            var execOptions = new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            };

            var openFile      = new TransformBlock <string, string>(async path => await File.ReadAllTextAsync(path), execOptions);
            var generateTests = new TransformManyBlock <string, TestUnit>(file => TestsGenerator.Generate(file), execOptions);
            var writeFile     = new ActionBlock <TestUnit>(
                async testUnit => await File.WriteAllTextAsync(
                    Path.Combine(resultPath, testUnit.Name) + ".cs", testUnit.Test),
                execOptions);


            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            openFile.LinkTo(generateTests, linkOptions);
            generateTests.LinkTo(writeFile, linkOptions);


            foreach (string path in files)
            {
                openFile.Post(path);
            }
            openFile.Complete();

            return(writeFile.Completion);
        }
        public void CheckUsings()
        {
            TestUnit[] actualUnits = TestsGenerator.GenerateTests(sourceCode);

            string[] actual1 = CSharpSyntaxTree.ParseText(actualUnits[0].sourceCode).
                               GetRoot().
                               DescendantNodes().OfType <UsingDirectiveSyntax>().
                               Select(use => use.Name.ToString()).
                               ToArray();
            string[] actual2 = CSharpSyntaxTree.ParseText(actualUnits[1].sourceCode).
                               GetRoot().
                               DescendantNodes().OfType <UsingDirectiveSyntax>().
                               Select(use => use.Name.ToString()).
                               ToArray();

            string[] expected1 = { "CustomNamespace1", "System", "System.Collections.Generic", "System.Text" };
            string[] expected2 = { "CustomNamespace2", "System", "System.Collections.Generic", "System.Text" };

            Assert.AreEqual(expected1[0], actual1[0]);
            Assert.AreEqual(expected1[1], actual1[1]);
            Assert.AreEqual(expected1[2], actual1[2]);
            Assert.AreEqual(expected1[3], actual1[3]);

            Assert.AreEqual(expected2[0], actual2[0]);
            Assert.AreEqual(expected2[1], actual2[1]);
            Assert.AreEqual(expected2[2], actual2[2]);
            Assert.AreEqual(expected2[3], actual2[3]);
        }
Example #10
0
        static void Main(string[] args)
        {
            int readingTasksCount = Convert.ToInt32(args[0]);
            int writingTasksCount = Convert.ToInt32(args[1]);

            TestGeneratorConfig config = new TestGeneratorConfig(readingTasksCount, writingTasksCount);

            string        outputDirectory = args[2];
            List <string> paths           = new List <string>();

            for (int i = 3; i < args.Length; i++)
            {
                paths.Add(args[i]);
            }

            CodeReader reader = new CodeReader();
            CodeWriter writer = new CodeWriter(outputDirectory);

            TestsGenerator generator = new TestsGenerator(config);

            generator.Generate(reader, writer, paths).Wait();

            Console.WriteLine("Done!");

            Console.ReadLine();
        }
Example #11
0
        public void TestSimleClass()
        {
            string SimpleClassTest = @"namespace SimpleNamespace
                                            {
                                                class SimpleClass
                                                {
                                                    private void PrivateMeth() { }
                                                    public void VoidMeth(int k, float b) { }

                                                    public char CharMeth(string s)
                                                    {
                                                        return 'F';
                                                    }
                                                }
                                            }";

            Tests[] tests = TestsGenerator.GenerateTests(SimpleClassTest);

            string ExpectredText = @"using NUnit.Framework;
using Moq;
using SimpleNamespace;

namespace SimpleNamespace.Test
{
    [TestFixture]
    public class SimpleClassTests
    {
        private SimpleClass _SimpleClassUnderTest;
        [SetUp]
        public void SetUp()
        {
            _SimpleClassUnderTest = new SimpleClass();
        }

        [Test]
        public void VoidMethTest()
        {
            int k = default;
            float b = default;
            _SimpleClassUnderTest.VoidMeth(k, b);
            Assert.Fail(" + "\"autogenerated\"" + @");
        }

        [Test]
        public void CharMethTest()
        {
            string s = default;
            char actual = _SimpleClassUnderTest.CharMeth(s);
            char expected = default;
            Assert.That(actual, Is.EqualTo(expected));
            Assert.Fail(" + "\"autogenerated\"" + @");
        }
    }
}";

            Assert.AreEqual(tests.Length, 1);
            Assert.AreEqual(ExpectredText, tests[0].TestCode);
        }
Example #12
0
        public void TestStaticClass()
        {
            string StaticClassTest = @"namespace StaticName
                                        {
                                            static class StaticClass
                                            {
                                                public static void VoidMeth(bool Bool, int k)
                                                {

                                                }

                                                public static bool BoolMeth(string s)
                                                {
                                                    return true;
                                                }
                                            }
                                        }";

            Tests[] tests         = TestsGenerator.GenerateTests(StaticClassTest);
            string  ExpectredText = @"using NUnit.Framework;
using Moq;
using StaticName;

namespace StaticName.Test
{
    [TestFixture]
    public class StaticClassTests
    {
        [SetUp]
        public void SetUp()
        {
        }

        [Test]
        public void VoidMethTest()
        {
            bool Bool = default;
            int k = default;
            StaticClass.VoidMeth(Bool, k);
            Assert.Fail(" + "\"autogenerated\"" + @");
        }

        [Test]
        public void BoolMethTest()
        {
            string s = default;
            bool actual = StaticClass.BoolMeth(s);
            bool expected = default;
            Assert.That(actual, Is.EqualTo(expected));
            Assert.Fail(" + "\"autogenerated\"" + @");
        }
    }
}";

            Assert.AreEqual(tests.Length, 1);
            Assert.AreEqual(ExpectredText, tests[0].TestCode);
        }
Example #13
0
        public void SetUp(string name)
        {
            FileSource file      = new FileSource(File.ReadAllBytes($"{name}.cs.testable"), "");
            var        generator = new TestsGenerator();
            var        t         = generator.GetGenerator(file);

            t.Wait();
            SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(Encoding.Default.GetString(t.Result.First().Data));

            compilationUnitSyntax = syntaxTree.GetCompilationUnitRoot();
        }
        public void Init()
        {
            outputDirectory = Path.Combine("..", "..", "TestDirectoryOutput");
            inputDirectory  = Path.Combine("..", "..", "TestDirectoryInput");

            writer    = new TestWriter(outputDirectory);
            reader    = new TestReader();
            generator = new TestsGenerator(1, 1, 1, writer, reader);
            generator.Generate(Directory.GetFiles(inputDirectory).ToList()).Wait();

            generatedUnit = ParseCompilationUnit(File.ReadAllText(Path.Combine(outputDirectory, "TestClasses.cs")));
        }
Example #15
0
        static void Main(string[] args)
        {
            string        sourceDirectory;
            string        targetDirectory;
            int           countOfReadThreads;
            int           countOfWriteThreads;
            int           countOfProcessThreads;
            List <string> inputFiles = new List <string>();

            //Entering source folder path
            Console.WriteLine("Enter the source folder path:");
            sourceDirectory = Console.ReadLine();

            //Entering destination folder path
            Console.WriteLine("Enter the target folder path:");
            targetDirectory = Console.ReadLine();

            //Entering conveyor parameteres
            Console.WriteLine("Enter the count of read threads:");
            countOfReadThreads = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter the count of process threads:");
            countOfProcessThreads = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter the count of write threads:");
            countOfWriteThreads = Convert.ToInt32(Console.ReadLine());

            try
            {
                string[] fileEntries = Directory.GetFiles(sourceDirectory);
                foreach (string fileName in fileEntries)
                {
                    inputFiles.Add(fileName);
                }
            }
            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("Directory not found");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex.Message}");
            }


            var config = new Config(countOfReadThreads, countOfProcessThreads, countOfWriteThreads);

            var generator = new TestsGenerator(config);

            generator.Generate(inputFiles, targetDirectory).Wait();

            Console.WriteLine("Generation ended");
            Console.ReadKey();
        }
Example #16
0
        public void EmptyClassTest()
        {
            string testStr = @" namespace CustomNamespace
                                {
                                    public class Custom
                                    {

                                    }

                                }";

            TestUnit[] tests = TestsGenerator.Generate(testStr);
            Assert.AreEqual(0, tests.Count());
        }
Example #17
0
        public void SetUp()
        {
            resultPath  = Environment.CurrentDirectory + "\\ResultTests";
            asyncWriter = new AsyncFileWriter(resultPath);

            files = new List <string>();
            string pathToFile1 = Environment.CurrentDirectory + "\\SourceCodeFiles\\Class.cs";

            files.Add(pathToFile1);

            maxReadableCount    = 3;
            maxProcessableCount = 3;
            maxWritableCount    = 3;
            testsGenerator      = new TestsGenerator(files, maxReadableCount, maxProcessableCount, maxWritableCount);
        }
        public void CheckNamespaceGeneration()
        {
            var actualUnits = TestsGenerator.GenerateTests(sourceCode);

            var actual1 = CSharpSyntaxTree.ParseText(actualUnits[0].sourceCode).GetRoot().DescendantNodes()
                          .OfType <NamespaceDeclarationSyntax>().Select(space => space.Name.ToString()).ToArray();
            var actual2 = CSharpSyntaxTree.ParseText(actualUnits[1].sourceCode).GetRoot().DescendantNodes()
                          .OfType <NamespaceDeclarationSyntax>().Select(space => space.Name.ToString()).ToArray();

            string[] expected1 = { "Custom1UnitTests" };
            string[] expected2 = { "Custom2UnitTests" };

            Assert.AreEqual(expected1[0], actual1[0]);
            Assert.AreEqual(expected2[0], actual2[0]);
        }
        public void CheckClassGeneration()
        {
            var actualUnits = TestsGenerator.GenerateTests(sourceCode);

            var actual1 = CSharpSyntaxTree.ParseText(actualUnits[0].sourceCode).GetRoot().DescendantNodes()
                          .OfType <ClassDeclarationSyntax>().First().Identifier.ValueText;
            var actual2 = CSharpSyntaxTree.ParseText(actualUnits[1].sourceCode).GetRoot().DescendantNodes()
                          .OfType <ClassDeclarationSyntax>().First().Identifier.ValueText;

            var expected1 = "Custom1Tests";
            var expected2 = "Custom2Tests";

            Assert.AreEqual(expected1, actual1);
            Assert.AreEqual(expected2, actual2);
        }
Example #20
0
        public void Setup()
        {
            methodList = new List <string>()
            {
                "CanGenerateTest", "GenerateTest"
            };

            TestsGenerator  generator = new TestsGenerator();
            List <TestFile> testFiles = generator.CreateTests(File.ReadAllText("ListGenerator.cs"));

            roots = new List <SyntaxNode>();
            foreach (TestFile testFile in testFiles)
            {
                roots.Add(CSharpSyntaxTree.ParseText(testFile.Code).GetRoot());
            }
        }
Example #21
0
        static void Main(string[] args)
        {
            int           readingLimit    = 5;
            int           writingLimit    = 5;
            int           processingLimit = 10;
            string        workPath        = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName + "\\TestsFiles\\";
            List <string> pathes          = new List <string>
            {
                workPath + "MyClass.cs",
                workPath + "Tracer.cs"
            };

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

            generator.Generate(pathes, workPath + "GeneratedTests").Wait();
        }
Example #22
0
        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();
        }
Example #23
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");
        }
        public void CheckPrivateFieldsGeneration()
        {
            var actualUnits = TestsGenerator.GenerateTests(sourceCode);

            var actual1 = CSharpSyntaxTree.ParseText(actualUnits[0].sourceCode).GetRoot().DescendantNodes()
                          .OfType <FieldDeclarationSyntax>().Select(f => f.Declaration.Variables[0].Identifier.ValueText)
                          .ToArray();
            var actual2 = CSharpSyntaxTree.ParseText(actualUnits[1].sourceCode).GetRoot().DescendantNodes()
                          .OfType <FieldDeclarationSyntax>().Select(f => f.Declaration.Variables[0].Identifier.ValueText)
                          .ToArray();

            string[] expected1 = { "_Custom1Instance", "_cDependency" };
            string[] expected2 = { "_Custom2Instance" };

            Assert.AreEqual(expected1[0], actual1[0]);
            Assert.AreEqual(expected1[1], actual1[1]);

            Assert.AreEqual(expected2[0], actual2[0]);
        }
Example #25
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();
        }
Example #26
0
        static void Main(string[] args)
        {
            TestsGenerator generator = new TestsGenerator();
            ExecutionDataflowBlockOptions blockOptions = new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = 3
            };
            TransformBlock <string, string> getCode = new TransformBlock <string, string>
                                                      (
                async filePath => await File.ReadAllTextAsync(filePath),
                blockOptions
                                                      );

            TransformManyBlock <string, TestFile> createTests = new TransformManyBlock <string, TestFile>
                                                                (
                async sourceCode => await Task.Run(() => generator.CreateTests(sourceCode).ToArray()),
                blockOptions
                                                                );

            ActionBlock <TestFile> saveTests = new ActionBlock <TestFile>
                                               (
                async testsFile => await File.WriteAllTextAsync(Directory.GetCurrentDirectory() + "\\Tests\\" + testsFile.Name, testsFile.Code),
                blockOptions
                                               );

            DataflowLinkOptions linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            getCode.LinkTo(createTests, linkOptions);
            createTests.LinkTo(saveTests, linkOptions);

            string[] filePaths = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Files\\");

            foreach (string filePath in filePaths)
            {
                if (filePath.EndsWith(".cs"))
                {
                    getCode.Post(filePath);
                }
            }
            getCode.Complete();
            saveTests.Completion.Wait();
        }
Example #27
0
        public Task Generate(string destFolder, string[] filenames, int maxPipelineTasks)
        {
            var execOptions = new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = maxPipelineTasks
            };
            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            Directory.CreateDirectory(destFolder);

            var loadFile = new TransformBlock <string, string>
                           (
                async path => await File.ReadAllTextAsync(path),
                execOptions
                           );
            var generateTests = new TransformManyBlock <string, TestUnit>
                                (
                async sourceCode => await Task.Run(() => TestsGenerator.GenerateTests(sourceCode)),
                execOptions
                                );
            var writeFile = new ActionBlock <TestUnit>
                            (
                async filesContent =>
            {
                await File.WriteAllTextAsync(destFolder + '\\' + filesContent.filename + ".cs",
                                             filesContent.sourceCode);
            },
                execOptions
                            );

            loadFile.LinkTo(generateTests, linkOptions);
            generateTests.LinkTo(writeFile, linkOptions);

            foreach (var filename in filenames)
            {
                loadFile.Post(filename);
            }

            loadFile.Complete();
            return(writeFile.Completion);
        }
Example #28
0
        public void Initialize()
        {
            string path = "TestClass.cs";

            int countOfReadThreads    = 2;
            int countOfProcessThreads = 3;
            int countOfWriteThreads   = 4;
            var сonfig    = new Config(countOfReadThreads, countOfProcessThreads, countOfWriteThreads);
            var generator = new TestsGenerator(сonfig);

            string sourceCode;

            using (StreamReader strmReader = new StreamReader(path))
            {
                sourceCode = strmReader.ReadToEnd();
            }

            var parcer = new SourceCodeParcer();

            parcedClasses  = parcer.Parce(sourceCode);
            generatedTests = generator.GenerateTests(sourceCode);
        }
Example #29
0
        public void TestManyClass()
        {
            string ManyClassTest = @"namespace InterfaceName
                        {
                            class TestClass { }
                            interface ITestInt { }
                            interface IMoreInt { }
                            class ClassWithInter
                            {
                                public ClassWithInter(int i, ITestInt testInt)
                                {
                                }
                                private void PrivateMeth() { }
                                public void VoidMeth(int k, float b, ITestInt test) { }

                                public char CharMeth(TestClass test)
                                {
                                    return 'F';
                                }
                            }
                            class ClassWithTwoInter
                            {
                                public ClassWithTwoInter(int i, ITestInt testInt, IMoreInt moreInt)
                                {
                                }

                                public char CharMeth(TestClass test)
                                {
                                    return 'F';
                                }
                            }
                        }";

            Tests[] tests = TestsGenerator.GenerateTests(ManyClassTest);

            Assert.AreEqual(tests.Length, 2);
        }
Example #30
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);
            }
        }