예제 #1
0
        public Task Generate(List <string> source, string destination, int maxParallelism)
        {
            var executionOptions = new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = maxParallelism
            };
            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            var openFile = new TransformBlock <string, string>(async path =>
                                                               await fileIO.ReadFileAsync(path),
                                                               executionOptions);

            var generateTest = new TransformBlock <string, List <TestFile> >(text =>
            {
                return(generator.CreateTest(text));
            }, executionOptions);

            var saveTestFile = new ActionBlock <List <TestFile> >(async text =>
            {
                await fileIO.WriteFileAsync(destination, text);
            }, executionOptions);

            openFile.LinkTo(generateTest, linkOptions);
            generateTest.LinkTo(saveTestFile, linkOptions);

            foreach (var file in source)
            {
                openFile.Post(file);
            }

            openFile.Complete();
            return(saveTestFile.Completion);
        }
예제 #2
0
        public void CompareTestCode()
        {
            var code = File.ReadAllText(Directory.GetCurrentDirectory() + @"\Code\Code.cs");
            List <TestsGeneratorLib.TestFile> result = gen.CreateTest(code);

            string expected = File.ReadAllText(dirPath + "\\TestGenerator.Test\\testcode.txt");
            string actual   = result[0].TestCode;

            Assert.AreEqual(expected, actual);
        }