Example #1
0
            public void Should_Recursively_Move_Files_And_Directory()
            {
                // Given
                var context     = Substitute.For <ICakeContext>();
                var environment = FakeEnvironment.CreateUnixEnvironment();
                var fileSystem  = new FakeFileSystem(environment);

                CreateFileStructure(fileSystem);
                context.FileSystem.Returns(fileSystem);
                var sourcePath      = new DirectoryPath("/Temp");
                var destinationPath = new DirectoryPath("/Temp2");

                // When
                DirectoryAliases.MoveDirectory(context, sourcePath, destinationPath);

                // Then
                Assert.False(fileSystem.GetDirectory("/Temp/Stuff").Exists);
                Assert.False(fileSystem.GetDirectory("/Temp/Things").Exists);
                Assert.True(fileSystem.GetDirectory("/Temp2/Stuff").Exists);
                Assert.True(fileSystem.GetDirectory("/Temp2/Things").Exists);

                Assert.False(fileSystem.GetFile("/Temp/Stuff/file1.txt").Exists);
                Assert.False(fileSystem.GetFile("/Temp/Stuff/file2.txt").Exists);
                Assert.False(fileSystem.GetFile("/Temp/Things/file1.txt").Exists);
                Assert.True(fileSystem.GetFile("/Temp2/Stuff/file1.txt").Exists);
                Assert.True(fileSystem.GetFile("/Temp2/Stuff/file2.txt").Exists);
                Assert.True(fileSystem.GetFile("/Temp2/Things/file1.txt").Exists);
            }
Example #2
0
        internal void GivenDirectoryExistsInToolsPath(string name)
        {
            var toolsFolder = FileSystem.GetDirectory(
                Configuration.GetToolPath(Environment.WorkingDirectory, Environment));

            var target = toolsFolder.Path.Combine(name);

            if (!FileSystem.Exist(target))
            {
                FileSystem.CreateDirectory(target);
            }
        }
        public ScriptProcessorFixture()
        {
            Environment = FakeEnvironment.CreateUnixEnvironment();
            FileSystem  = new FakeFileSystem(Environment);

            Log             = Substitute.For <ICakeLog>();
            Installer       = Substitute.For <INuGetPackageInstaller>();
            ApplicationRoot = new DirectoryPath("/Working/Bin");

            AssembliesLocator = Substitute.For <INuGetPackageAssembliesLocator>();
            AssembliesLocator.FindAssemblies(Arg.Any <DirectoryPath>()).Returns(
                ci =>
            {
                var dir = FileSystem.GetDirectory(ci.Arg <DirectoryPath>());
                return(dir.GetFiles("*.dll", SearchScope.Recursive).ToArray());
            });

            // Create the script analyzer result.
            var script1 = new ScriptInformation("/Working/build.cake");

            script1.Addins.Add(new NuGetPackage("Addin")
            {
                Source = "http://example.com"
            });
            script1.Tools.Add(new NuGetPackage("Tool")
            {
                Source = "http://example.com"
            });
            Result = new ScriptAnalyzerResult(script1, new List <string>());
        }
Example #4
0
            public void Should_Create_Destination_Folder_If_Not_Exist()
            {
                // Given
                var context = Substitute.For<ICakeContext>();
                var environment = FakeEnvironment.CreateUnixEnvironment();
                var fileSystem = new FakeFileSystem(environment);
                CreateFileStructure(fileSystem);
                context.FileSystem.Returns(fileSystem);
                var sourcePath = new DirectoryPath("/Temp");
                var destinationPath = new DirectoryPath("/Temp2");

                // When
                DirectoryAliases.CopyDirectory(context, sourcePath, destinationPath);

                // Then
                Assert.True(fileSystem.GetDirectory(destinationPath).Exists);
            }