// レジストリ値をコピー private void CopyRegistryValue(string source, string destination, string name, string destinationName) { using (RegistryKey sourceKey = RegistryControl.GetRegistryKey(source, false, true)) using (RegistryKey destinationKey = RegistryControl.GetRegistryKey(destination, true, true)) { RegistryValueKind valueKind = sourceKey.GetValueKind(name); object sourceValue = valueKind == RegistryValueKind.ExpandString ? sourceKey.GetValue(name, null, RegistryValueOptions.DoNotExpandEnvironmentNames) : sourceKey.GetValue(name); if (destinationName == null) { destinationName = name; } // テスト自動生成 if (Test != null) { TestGenerator.RegistryName(source, name); TestGenerator.RegistryName(destination, destinationName); TestGenerator.RegistryType(destination, destinationName, RegistryControl.ValueKindToString(valueKind)); TestGenerator.RegistryValue(destination, destinationName, RegistryControl.RegistryValueToString(sourceKey, name, valueKind, true)); } destinationKey.SetValue(destinationName, sourceValue, valueKind); // コピー元を削除する場合 sourceKey.DeleteValue(name); } }
public void LucaDemoGeneratedTest() { SyntaxTree tree = SyntaxTree.CreateFromString(@" x= 1 -- this is an add function add = function(x, y) return x+y;-- adding end get_zero = function() return 0 end"); var generator = new TestGenerator(); generator.GenerateTestFromString(@" x= 1 -- this is an add function add = function(x, y) return x+y;-- adding end get_zero = function() return 0 end", "LucaDemo"); Debug.WriteLine(tree.ErrorList.Count); new LucaDemo_Generated().Test(new Tester(tree)); Assert.Equal(0, tree.ErrorList.Count); }
protected override void ProcessRecord() { // テスト自動生成 TestGenerator.RegistryKey(Path); using (RegistryKey regKey = RegistryControl.GetRegistryKey(Path, true, true)) { } }
public void TestInit() { string sourceFilesDirectory = "..\\..\\..\\"; classOneName = "ClassForTest1Tests.cs"; classTwoName = "ClassForTest2Tests.cs"; string souceClassPath = Path.Combine(sourceFilesDirectory, "ClassForTest.cs"); sourceClassCode = File.ReadAllText(souceClassPath); generatedClasses = TestGenerator.Generate(sourceClassCode).Result; foreach (var genClass in generatedClasses) { if (genClass.Name == classOneName) { classOneCode = genClass.Code; } if (genClass.Name == classTwoName) { classTwoCode = genClass.Code; } } classOneRoot = CSharpSyntaxTree.ParseText(classOneCode).GetCompilationUnitRoot(); classTwoRoot = CSharpSyntaxTree.ParseText(classTwoCode).GetCompilationUnitRoot(); }
static void Main(string[] args) { Console.WriteLine("Enter list of file to generate tests for them separating them by spaces"); List <string> Files = Console.ReadLine().Split(' ').ToList(); List <string> FilesPath = new List <string>(); foreach (string File in Files) { FilesPath.Add(Path.GetFullPath(File)); } Console.WriteLine("Enter test folder"); string Folder = Path.GetFullPath(Console.ReadLine()); Console.WriteLine("Enter max amount of threads for generating tests"); int Threads = int.Parse(Console.ReadLine()); Console.WriteLine("Enter max amount of threads for reading files"); int FilesToRead = int.Parse(Console.ReadLine()); Console.WriteLine("Enter max amount of threads for writing files"); int FilesToWrite = int.Parse(Console.ReadLine()); TestGenerator generator = new TestGenerator(); Pipeline pipeline = new Pipeline(generator, FilesPath, Folder, Threads, FilesToRead, FilesToWrite); try { pipeline.GenerateAsync().Wait(); Console.WriteLine("Completed."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void OnGUI() { /* UI Objects */ GUILayout.Label("Level Data", EditorStyles.boldLabel); name = EditorGUILayout.TextField("Level Name", name); sizeX = EditorGUILayout.TextField("Size X", sizeX); sizeY = EditorGUILayout.TextField("Size Y", sizeY); EditorGUILayout.PrefixLabel("Level Description"); description = EditorGUILayout.TextArea(description, GUILayout.Height(position.height - 200)); /* On Generate Level button pushed */ if (GUI.Button(new Rect(5, position.height - 35, 250, 30), "Generate Level")) { // Create a new object in the scene, this object will be able to link the editor script to the scene. GameObject singular = GameObject.CreatePrimitive(PrimitiveType.Cube); singular.transform.position = new Vector3(100000, 100000, 100000); singular.name = "TestGenerator"; // Attach the generation script to the object TestGenerator testGenerator = singular.AddComponent <TestGenerator>(); // Create a level information struct for use in the generator LevelInformation information = new LevelInformation(name, description, sizeX, sizeY); // Create a level JSON file testGenerator.CreateLevelFile(information); // cleanup DestroyImmediate(singular); } }
static void Main(string[] args) { string inputFile, outputFile; Console.Write("Write input file (with extension part): "); inputFile = Console.ReadLine(); Console.Write("Write input file (with extension part): "); outputFile = Console.ReadLine(); if (inputFile != string.Empty && outputFile != string.Empty && inputFile.Contains('.')) { TestGenerator generator = new TestGenerator(inputFile, outputFile); int variants, questions; bool mix; Console.Write("Write number of variants to generate: "); variants = Convert.ToInt32(Console.ReadLine()); Console.Write("Write number of question per variant: "); questions = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Would you like to mix answers? (y/n) "); char c = Console.ReadKey().KeyChar; if (c=='y'||c=='Y') mix = true; else if (c=='n'||c=='N') mix = false; else throw new ArgumentException("I said you should say yes or no!"); generator.GenerateTest(variants, questions, mix); //Process.Start(generator.OutputFileName); } else { Console.WriteLine("Wrong put. Extension part is missed"); } }
protected override void ProcessRecord() { using (RegistryKey regKey = RegistryControl.GetRegistryKey(Path, false, true)) { if (Name == null) { // テスト自動生成 TestGenerator.RegistryKey(Path); try { regKey.DeleteSubKeyTree(""); } catch { using (Process proc = new Process()) { proc.StartInfo.FileName = "reg"; proc.StartInfo.Arguments = $"delete \"{Path}\" /f"; proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.Start(); proc.WaitForExit(); } } } else { // テスト自動生成 TestGenerator.RegistryName(Path, Name); regKey.DeleteValue(Name); } } }
public void StartBeforeEach() { List <string> files = new List <string>(Directory.GetFiles(@"C:\Users\lenovo\source\repos\MPP.lab4\ClassesForGeneratingTests")); directory = Directory.GetCurrentDirectory() + @"\Tests" + DateTime.Now.Ticks.ToString(); generator = new TestGenerator(directory); generator.GenerateTests(files, new DegreeOfParallelism(3, 3, 3)).Wait(); }
public ActionResult DeleteConfirmed(int id) { TestGenerator testGenerator = db.TestGenerators.Find(id); db.TestGenerators.Remove(testGenerator); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void Main(string[] args) { List <string> files = new List <string>(Directory.GetFiles(@"C:\Users\lenovo\source\repos\MPP.lab4\ClassesForGeneratingTests")); string dir = Directory.GetCurrentDirectory() + @"\Tests" + DateTime.Now.Ticks.ToString(); var gen = new TestGenerator(dir); gen.GenerateTests(files, new DegreeOfParallelism(3, 3, 3)).Wait(); }
public void GrabKeyFromTableGeneratedTest() { SyntaxTree tree = SyntaxTree.CreateFromString("t[\"this is a test that grabs this key in Lua\"]"); var generator = new TestGenerator(); generator.GenerateTestFromString("t[\"this is a test that grabs this key in Lua\"]", "GrabKeyFromTable"); new GrabKeyFromTable_Generated().Test(new Tester(tree)); }
public void BracketsErrorGeneratedTest() { SyntaxTree tree = SyntaxTree.CreateFromString("}("); var generator = new TestGenerator(); generator.GenerateTestFromString("}(", "BracketsError"); new BracketsError_Generated().Test(new Tester(tree)); }
protected override void BeginProcessing() { _generator = new TestGenerator(Test); // カレントディレクトリカレントディレクトリの一時変更 _currentDirectory = Environment.CurrentDirectory; Environment.CurrentDirectory = this.SessionState.Path.CurrentFileSystemLocation.Path; }
protected override void BeginProcessing() { Inherited = Item.CheckCase(Inherited); AccessControl = Item.CheckCase(AccessControl); _Rights = Item.CheckCase(Rights); _generator = new TestGenerator(Test); }
public void Counter_IsCorrectly_Transformed_UponInitialization() { var testGenerator = new TestGenerator(); var blockArray = testGenerator.TransformCounterToByteArray(); var counter = BitConverter.ToInt32(blockArray, 0); counter.Should().Be(1); }
/// <summary> /// Generates test cases in a test suite, yielding data in the working test generator). /// Returns true if all test cases are generated correctly. /// </summary> public bool GenerateTestSuite(out string testSuiteStatus) { workingTestGenerator = new TestGenerator(); bool populated = workingTestGenerator.PopulateTestSuite(workingTestSpecification, out testSuiteStatus); bool written = workingTestGenerator.WriteAsString(workingTestSpecification.Given); return(populated && written); }
public Pipeline(TestGenerator generator, List <string> files, string folder, int maxThreads, int maxFilesToRead, int maxFilesToWrite) { _generator = generator; _filesfortest = files; _testfolder = folder; _maxThreads = maxThreads; _maxFilesToRead = maxFilesToRead; _maxFilesToWrite = maxFilesToWrite; }
public static void Main(string[] args) { TestGenerator testGenerator = new TestGenerator(1, 1, 1, @"C:\Users\Max\Desktop"); testGenerator.Generate(new List <string>() { Path.Combine(@"C:\Users\Max\RiderProjects\Lab Task 4\TestGeneratorLib\Utils\Class1.cs"), }).Wait(); }
public void PrefixExpFirstGeneratedTest() { SyntaxTree tree = SyntaxTree.CreateFromString("(f)[s] = k"); var generator = new TestGenerator(); generator.GenerateTestFromString("(f)[s] = k", "PrefixExpFirst"); new PrefixExpFirst_Generated().Test(new Tester(tree)); Assert.Equal(0, tree.ErrorList.Count); }
public void EmptyProgramGeneratedTest() { SyntaxTree tree = SyntaxTree.CreateFromString(""); var generator = new TestGenerator(); generator.GenerateTestFromString("", "EmptyProgram"); new EmptyProgram_Generated().Test(new Tester(tree)); Assert.Equal(0, tree.ErrorList.Count); }
static void Main() { var loadSourceFiles = new TransformBlock <string, string>(async path => { Console.WriteLine("Loading {0} ...", path); using StreamReader reader = File.OpenText(path); return(await reader.ReadToEndAsync()); }, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = maxFilesToLoad }); var generateTestClasses = new TransformBlock <string, TestGenerator.Test>(async source => { Console.WriteLine("Generating test classes ..."); var generator = new TestGenerator(); return(await generator.GetTests(source)); }, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = maxTasks }); var writeToFile = new ActionBlock <TestGenerator.Test>(async testClass => { Console.WriteLine("Writing {0} to file...", testClass.fileName); using StreamWriter writer = File.CreateText(destPath + testClass.fileName); await writer.WriteAsync(testClass.code); }, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = maxFilesToWrite }); var linkOptions = new DataflowLinkOptions { PropagateCompletion = true }; loadSourceFiles.LinkTo(generateTestClasses, linkOptions); generateTestClasses.LinkTo(writeToFile, linkOptions); foreach (var item in filesPathes) { loadSourceFiles.Post(item); } // Mark the head of the pipeline as complete. loadSourceFiles.Complete(); // Wait for the last block in the pipeline to process all messages. writeToFile.Completion.Wait(); }
public void TestMethod1() { Form1 form = new Form1(); TestGenerator.Generate_Tests(); for (int i = 1; i <= 22; i++) { form.Convert_From_File($"test{i}.txt"); } }
public void PrefixExpNestedTest() { SyntaxTree tree = SyntaxTree.CreateFromString("foo.bar(t[5]).set():run{}"); Assert.Equal(0, tree.ErrorList.Count); var generator = new TestGenerator(); generator.GenerateTestFromString("foo.bar(t[5]).set():run{}", "PrefixExpNested"); new PrefixExpNested_Generated().Test(new Tester(tree)); }
protected override void BeginProcessing() { Inherited = Item.CheckCase(Inherited); _Attributes = Item.CheckCase(Attributes); _generator = new TestGenerator(Test); // カレントディレクトリカレントディレクトリの一時変更 _currentDirectory = Environment.CurrentDirectory; Environment.CurrentDirectory = this.SessionState.Path.CurrentFileSystemLocation.Path; }
public void Setup() { string fileContent; using (var fStream = new StreamReader(@"ListGenerator.cs")) { fileContent = fStream.ReadToEnd(); } _result = TestGenerator.Generate(fileContent); }
public void Generator_Changes_StateKey_After_Request() { var testArray = new byte[10]; var testGenerator = new TestGenerator(); var initialKey = testGenerator.ReturnStateKey(); testGenerator.GenerateDataPerStateKey(testArray); var updatedKey = testGenerator.ReturnStateKey(); initialKey.Should().NotBeEquivalentTo(updatedKey); }
public void Counter_IsIncremented_AfterReseed() { var testGenerator = new TestGenerator(); testGenerator.Reseed(new byte[] { }); var blockArray = testGenerator.TransformCounterToByteArray(); var counter = BitConverter.ToInt32(blockArray, 0); counter.Should().Be(2); }
public void ProcessingJsonTestSpecificationYieldsTestScript(string inputFilename, string outputFilename) { string inputFilenameWithPath = $"{FileHelper.PathTestGenerator}\\{inputFilename}"; string outputFilenameWithPath = $"{FileHelper.PathTestGenerator}\\{outputFilename}"; TestGenerator testGenerator = new TestGenerator(); Assert.True( testGenerator.CreateSuiteFromSpecificationAndWrite(inputFilenameWithPath, outputFilenameWithPath), $"Failed to create test suite from test specification in {inputFilename} and write it to {outputFilename}"); }
public void Init() { _inputDirectory = Path.Combine("..", "..", "..", "TestFiles"); _outputDirectory = Path.Combine("..", "..", "..", "TestDirectoryOutput"); _testGenerator = new TestGenerator(1, 1, 1, _outputDirectory); var testFiles = Directory.GetFiles(_inputDirectory).ToList(); _testGenerator.Generate(testFiles).Wait(); }
// Start is called before the first frame update void Start() { train = GetComponent <TrainGenerator>(); test = GetComponent <TestGenerator>(); ShapeGenerator generator = new TreeShape(); // train.render = false; train.StartTrain(generator); StartCoroutine(TestCallback()); }