/// <summary> /// Saves all tests from the execution context as separate files in tests directory. /// Full paths to the files are preserved in a private field. /// </summary> /// <param name="tests">All tests from the execution context</param> private void SaveTests(IList <TestContext> tests) { var testsDirectoryName = FileHelpers.BuildPath(this.WorkingDirectory, TestsFolderName); this.testPaths = new string[tests.Count]; for (var i = 0; i < tests.Count; i++) { var test = tests[i]; var testFileName = $"test_{i}{PythonFileExtension}"; var testSavePath = FileHelpers.BuildPath(testsDirectoryName, testFileName); PythonStrategiesHelper.CreateFileInPackage(testSavePath, test.Input); this.testPaths[i] = testSavePath; } }
/// <summary> /// Generates and saves all python files that are being tested by the user. /// Files are extracted and generated by the test input, which contains all file contents in a single string. /// </summary> /// <param name="expectedFilesCount">Predefined value that acts as a validity check</param> /// <param name="test">The test on which the operation is performed</param> /// <exception cref="ArgumentException">Thrown if the expected files count does not match the captured files from the test</exception> private void SaveTestProjectFiles(int expectedFilesCount, TestContext test) { var projectFilesToBeCreated = this.GetProjectFilesToBeCreated(test); if (projectFilesToBeCreated.Count != expectedFilesCount) { throw new ArgumentException(string.Format( ProjectFilesNotCapturedCorrectlyErrorMessageTemplate, expectedFilesCount, test.Id, projectFilesToBeCreated.Count)); } foreach (var projectFile in projectFilesToBeCreated) { PythonStrategiesHelper.CreateFileInPackage(projectFile.Key, projectFile.Value); } }