예제 #1
0
        private static void CreateTestModule()
        {
            if (File.Exists(zipPath))
            {
                Debug.LogWarning($"Test module path {zipPath} already exists, deleting it.");
                File.Delete(zipPath);
                if (File.Exists(zipPath))
                {
                    throw new Exception($"Test module already exists: {zipPath}");
                }
            }

            string sourceFolderPath = sourcePath + TestModuleMetadata.TargetPath;

            Directory.CreateDirectory(sourceFolderPath);
            string textFileLoc = sourceFolderPath + Path.DirectorySeparatorChar + TestTextFileFolder;

            Directory.CreateDirectory(textFileLoc);

            Stream metadataFile = File.Open(sourceFolderPath + Path.DirectorySeparatorChar + ModuleMetadata.MetadataFilename, FileMode.OpenOrCreate);

            TestModuleMetadata.Serialize(metadataFile);
            metadataFile.Close();

            Stream textFile = File.Open(textFileLoc + Path.DirectorySeparatorChar + TestTextFileName, FileMode.OpenOrCreate);
            var    writer   = new StreamWriter(textFile);

            writer.Write(TestTextFileContents);
            writer.Flush();
            textFile.Close();

            ZipFile.CreateFromDirectory(sourceFolderPath, zipPath);

            Directory.Delete(sourceFolderPath, true);
        }