Example #1
0
        private static FakeFileSystem CreateFileSystem(bool isUnix)
        {
            var fileSystem = new FakeFileSystem(isUnix);

            fileSystem.GetCreatedDirectory("/Temp");
            fileSystem.GetCreatedDirectory("/Temp/HasDirectories");
            fileSystem.GetCreatedDirectory("/Temp/HasDirectories/A");
            fileSystem.GetCreatedDirectory("/Temp/HasFiles");
            fileSystem.GetCreatedDirectory("/Temp/Hello");
            fileSystem.GetCreatedDirectory("/Temp/Hello/Empty");
            fileSystem.GetCreatedDirectory("/Temp/Hello/More/Empty");
            fileSystem.GetCreatedDirectory("/Temp/Hello/World");
            fileSystem.GetCreatedDirectory("/Temp/Goodbye");
            fileSystem.GetCreatedDirectory("/Temp/Hello/Hidden", true);
            fileSystem.GetCreatedFile("/Presentation.ppt");
            fileSystem.GetCreatedFile("/Budget.xlsx");
            fileSystem.GetCreatedFile("/Text.txt");
            fileSystem.GetCreatedFile("/Temp");
            fileSystem.GetCreatedFile("/Temp/Hello/Document.txt");
            fileSystem.GetCreatedFile("/Temp/Hello/World/Text.txt");
            fileSystem.GetCreatedFile("/Temp/Hello/World/Picture.png");
            fileSystem.GetCreatedFile("/Temp/Hello/Hidden.txt", true);
            fileSystem.GetCreatedFile("/Temp/Goodbye/OtherText.txt");
            fileSystem.GetCreatedFile("/Temp/Goodbye/OtherPicture.png");
            fileSystem.GetCreatedFile("/Temp/HasFiles/A.txt");
            return(fileSystem);
        }
        public XmlTransformationFixture(bool xmlExists = true, bool xslExists = true, bool resultExist = false)
        {
            Settings = new XmlTransformationSettings();

            var fileSystem = new FakeFileSystem(false);

            fileSystem.GetCreatedDirectory("/Working");

            if (xmlExists)
            {
                var xmlFile = fileSystem.GetCreatedFile("/Working/breakfast_menu.xml", Resources.XmlTransformation_Xml);
                XmlPath = xmlFile.Path;
            }

            if (xslExists)
            {
                var xslFile = fileSystem.GetCreatedFile("/Working/breakfast_menu.xsl", Resources.XmlTransformation_Xsl);
                XslPath = xslFile.Path;
            }

            if (resultExist)
            {
                var resultFile = fileSystem.GetCreatedFile("/Working/breakfast_menu.htm", Resources.XmlTransformation_Htm);
                ResultPath = resultFile.Path;
            }
            else
            {
                ResultPath = "/Working/breakfast_menu.htm";
            }

            FileSystem = fileSystem;
        }
Example #3
0
        private static FakeFileSystem CreateFileSystem(bool isUnix)
        {
            var fileSystem = new FakeFileSystem(isUnix);

            fileSystem.GetCreatedDirectory("/Temp");
            fileSystem.GetCreatedDirectory("/Temp/Hello");
            fileSystem.GetCreatedDirectory("/Temp/Hello/World");
            fileSystem.GetCreatedDirectory("/Temp/Goodbye");
            fileSystem.GetCreatedFile("/Presentation.ppt");
            fileSystem.GetCreatedFile("/Budget.xlsx");
            fileSystem.GetCreatedFile("/Text.txt");
            fileSystem.GetCreatedFile("/Temp");
            fileSystem.GetCreatedFile("/Temp/Hello/World/Text.txt");
            fileSystem.GetCreatedFile("/Temp/Hello/World/Picture.png");
            fileSystem.GetCreatedFile("/Temp/Goodbye/OtherText.txt");
            fileSystem.GetCreatedFile("/Temp/Goodbye/OtherPicture.png");
            return(fileSystem);
        }
Example #4
0
        public GlobberFixture(bool isFileSystemCaseSensitive)
        {
            FileSystem = new FakeFileSystem(isFileSystemCaseSensitive);
            FileSystem.GetCreatedDirectory("/Temp");
            FileSystem.GetCreatedDirectory("/Temp/Hello");
            FileSystem.GetCreatedDirectory("/Temp/Hello/World");
            FileSystem.GetCreatedDirectory("/Temp/Goodbye");
            FileSystem.GetCreatedFile("/Presentation.ppt");
            FileSystem.GetCreatedFile("/Budget.xlsx");
            FileSystem.GetCreatedFile("/Text.txt");
            FileSystem.GetCreatedFile("/Temp");
            FileSystem.GetCreatedFile("/Temp/Hello/World/Text.txt");
            FileSystem.GetCreatedFile("/Temp/Hello/World/Picture.png");
            FileSystem.GetCreatedFile("/Temp/Goodbye/OtherText.txt");
            FileSystem.GetCreatedFile("/Temp/Goodbye/OtherPicture.png");
            FileSystem.GetCreatedFile("/Working/Text.txt");
            FileSystem.GetCreatedFile("C:/Temp/Hello/World/Text.txt");

            Environment = Substitute.For <ICakeEnvironment>();
            Environment.IsUnix().Returns(isFileSystemCaseSensitive);
            Environment.WorkingDirectory.Returns("/Temp");
        }
Example #5
0
            public void Should_Return_True_If_Directory_Exist()
            {
                // Given
                var context    = Substitute.For <ICakeContext>();
                var fileSystem = new FakeFileSystem(false);

                fileSystem.GetCreatedDirectory("some path");
                context.FileSystem.Returns(fileSystem);

                // When
                var result = DirectoryAliases.DirectoryExists(context, "some path");

                // Then
                Assert.True(result);
            }
Example #6
0
        private MSBuildRunnerFixture(bool is64BitOperativeSystem, bool msBuildFileExist, IEnumerable <DirectoryPath> existingMSBuildPaths)
        {
            Process = Substitute.For <IProcess>();

            ProcessRunner = Substitute.For <IProcessRunner>();
            ProcessRunner.Start(Arg.Any <FilePath>(), Arg.Any <ProcessSettings>()).Returns(Process);

            Environment = Substitute.For <ICakeEnvironment>();
            Environment.Is64BitOperativeSystem().Returns(is64BitOperativeSystem);
            Environment.GetSpecialPath(SpecialPath.ProgramFilesX86).Returns("/Program86");
            Environment.GetSpecialPath(SpecialPath.Windows).Returns("/Windows");
            Environment.WorkingDirectory.Returns("/Working");

            Settings             = new MSBuildSettings("./src/Solution.sln");
            Settings.ToolVersion = MSBuildToolVersion.VS2013;

            if (existingMSBuildPaths != null)
            {
                // Add all existing MSBuild tool paths.
                var fileSystem = new FakeFileSystem(true);
                FileSystem = fileSystem;
                foreach (var existingPath in existingMSBuildPaths)
                {
                    fileSystem.GetCreatedDirectory(existingPath);
                    fileSystem.GetCreatedFile(existingPath.GetFilePath("MSBuild.exe"));
                }
            }
            else
            {
                FileSystem = Substitute.For <IFileSystem>();
                FileSystem.GetFile(
                    Arg.Is <FilePath>(p => p.FullPath.EndsWith("MSBuild.exe", System.StringComparison.Ordinal)))
                .Returns(c =>
                {
                    // All requested files exist.
                    var file = Substitute.For <IFile>();
                    file.Exists.Returns(msBuildFileExist);
                    file.Path.Returns(c.Arg <FilePath>());
                    return(file);
                });
            }
        }
Example #7
0
            private FakeFileSystem CreateFileStructure(FakeFileSystem ffs)
            {
                Action <string> dir  = path => ffs.GetCreatedDirectory(path);
                Action <string> file = path => ffs.GetCreatedFile(path);

                dir("C:/Temp");
                {
                    file("C:/Temp/file1.txt");
                    file("C:/Temp/file2.txt");
                    dir("C:/Temp/Stuff");
                    {
                        file("C:/Temp/Stuff/file1.txt");
                        file("C:/Temp/Stuff/file2.txt");
                    }
                    dir("C:/Temp/Things");
                    {
                        file("C:/Temp/Things/file1.txt");
                    }
                }

                return(ffs);
            }