/// <summary>
        /// Create a directory structure for use in testing.
        /// </summary>
        /// <param name="site"></param>
        public static void CreateExampleDirectoryStructure(FileSystemSite site, IStringlyTypedPathOperator stringlyTypedPathOperator)
        {
            var fileSystemOperator = site.FileSystemOperator;

            var baseDirectoryPath = site.DirectoryPath;

            // Create directories.
            var directory01Path = stringlyTypedPathOperator.GetDirectoryPath(baseDirectoryPath, ExampleDirectoryNames.Directory01);
            var directory02Path = stringlyTypedPathOperator.GetDirectoryPath(baseDirectoryPath, ExampleDirectoryNames.Directory02);
            var directory03Path = stringlyTypedPathOperator.GetDirectoryPath(directory02Path, ExampleDirectoryNames.Directory03);
            var directory04Path = stringlyTypedPathOperator.GetDirectoryPath(directory03Path, ExampleDirectoryNames.Directory04);

            foreach (var directoryPath in new string[] { directory01Path, directory02Path, directory03Path, directory04Path })
            {
                fileSystemOperator.CreateDirectoryOnlyIfNotExists(directoryPath);
            }

            // Create files.
            var file01Path = stringlyTypedPathOperator.GetFilePath(baseDirectoryPath, ExampleFileNames.File01Name);
            var file02Path = stringlyTypedPathOperator.GetFilePath(directory01Path, ExampleFileNames.File02Name);
            var file03Path = stringlyTypedPathOperator.GetFilePath(directory02Path, ExampleFileNames.File03Name);
            var file04Path = stringlyTypedPathOperator.GetFilePath(directory02Path, ExampleFileNames.File04Name);
            var file05Path = stringlyTypedPathOperator.GetFilePath(directory03Path, ExampleFileNames.File05Name);
            var file06Path = stringlyTypedPathOperator.GetFilePath(directory04Path, ExampleFileNames.File06Name);

            foreach (var filePath in new string[] { file01Path, file02Path, file03Path, file04Path, file05Path, file06Path })
            {
                using (var writer = fileSystemOperator.CreateFileText(filePath))
                {
                    writer.WriteLine("CONTENT!");
                }
            }
        }
示例#2
0
        public static string GetLocalTestingRootDirectoryPath(IStringlyTypedPathOperator stringlyTypedPathOperator)
        {
            var userDirectoryPath = PathHelper.UserProfileDirectoryPathValue;

            var randomDirectoryName = PathHelper.GetRandomDirectoryName();

            var rootDirectoryPath = stringlyTypedPathOperator.GetDirectoryPath(userDirectoryPath, randomDirectoryName);

            return(rootDirectoryPath);
        }