Exemplo n.º 1
0
            public void Should_Copy_Multiple_Files_Absolute_Path()
            {
                const string filePath1 = "./src/a/a.txt";
                const string filePath2 = "./src/b/b.txt";
                const string dstPath   = "./dst";

                // Given
                var fixture = new FileCopierFixture();

                fixture.EnsureFileExists(filePath1);
                fixture.EnsureFileExists(filePath2);
                fixture.EnsureDirectoryExists(dstPath);

                // When
                FileCopier.CopyFiles(
                    fixture.Context,
                    new[]
                {
                    fixture.MakeAbsolute(filePath1),
                    fixture.MakeAbsolute(filePath2)
                },
                    new DirectoryPath(dstPath),
                    true);

                // Then
                Assert.True(fixture.ExistsFile($"{dstPath}/a/a.txt"));
                Assert.True(fixture.ExistsFile($"{dstPath}/b/b.txt"));
            }
        public void Migrate(Job job)
        {
            var lister      = new SourceFilesLister();
            var sourceFiles = lister.GetSourceFiles(job.Source.Criteria);

            var fileCopier  = new FileCopier();
            var targetFiles = fileCopier.CopyFiles(sourceFiles, job.Source.ProjectFolder, job.Target.ProjectFolder);
        }
Exemplo n.º 3
0
            public void Should_Throw_If_Context_Is_Null()
            {
                // When
                var result = Record.Exception(() => FileCopier.CopyFiles(null, Enumerable.Empty <FilePath>(), new DirectoryPath(""), true));

                // Then
                AssertEx.IsArgumentNullException(result, "context");
            }
Exemplo n.º 4
0
            public void Should_Throw_If_Target_Directory_Path_Is_Null()
            {
                // Given
                var fixture = new FileCopierFixture();

                // When
                var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, Enumerable.Empty <FilePath>(), null, true));

                // Then
                AssertEx.IsArgumentNullException(result, "targetDirectoryPath");
            }
Exemplo n.º 5
0
            public void Should_Throw_If_File_Paths_Is_Null()
            {
                // Given
                var fixture = new FileCopierFixture();

                // When
                var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, (List <FilePath>)null, new DirectoryPath(""), true));

                // Then
                AssertEx.IsArgumentNullException(result, "filePaths");
            }
Exemplo n.º 6
0
            public void Should_Throw_If_Target_Directory_Does_Not_Exist()
            {
                const string dstPath = "/dst";

                // Given
                var fixture = new FileCopierFixture();

                // When
                var result = Record.Exception(() => FileCopier.CopyFiles(fixture.Context, Enumerable.Empty <FilePath>(), new DirectoryPath(dstPath), true));

                // Then
                AssertEx.IsExceptionWithMessage <DirectoryNotFoundException>(result, $"The directory '{dstPath}' does not exist.");
            }
Exemplo n.º 7
0
        private void CopyFiles()
        {
            Cursor currentCursor = Cursor.Current;

            currentCursor         = Cursors.WaitCursor;
            richTextBoxData.Text += @"Copying Files ...";
            richTextBoxData.Text += "\n";
            this.Refresh();
            FileCopier fc          = new FileCopier();
            int        filescopied = fc.CopyFiles();

            Cursor.Current        = currentCursor;
            richTextBoxData.Text += @"Files Copied ...";
        }
Exemplo n.º 8
0
            public void Should_Copy_Single_File_Relative_Path()
            {
                const string filePath = "./src/a/a.txt";
                const string dstPath  = "./dst";

                // Given
                var fixture = new FileCopierFixture();

                fixture.EnsureFileExists(filePath);
                fixture.EnsureDirectoryExists(dstPath);

                // When
                FileCopier.CopyFiles(
                    fixture.Context,
                    new FilePath[]
                {
                    filePath
                },
                    new DirectoryPath(dstPath),
                    true);

                // Then
                Assert.True(fixture.ExistsFile($"{dstPath}/a/a.txt"));
            }
Exemplo n.º 9
0
        public void TestFileCopier()
        {
            FileCopier fc = new FileCopier();

            Assert.IsTrue(fc.CopyFiles() > 0);
        }