示例#1
0
        public void CopyFile_OverExisting(bool useCreateFile)
        {
            using (var cleaner = new TestFileCleaner())
            {
                string source      = cleaner.CreateTestFile(CompressedFile2);
                string destination = cleaner.CreateTestFile($"CopyFile_OverExisting({useCreateFile})");

                CompressionMethods.LzCopyFile(source, destination, overwrite: true, useCreateFile: useCreateFile).Should().Be(563);
                FileHelper.ReadAllText(destination).Should().Be(CompressedContent2);
            }
        }
示例#2
0
        public void CopyFile_NotOverExisting(bool useCreateFile)
        {
            using (var cleaner = new TestFileCleaner())
            {
                string source      = cleaner.CreateTestFile(CompressedFile2);
                string destination = cleaner.CreateTestFile($"CopyFile_NotOverExisting({useCreateFile})");

                Action action = () => CompressionMethods.LzCopyFile(source, destination, overwrite: false, useCreateFile: useCreateFile);
                action.ShouldThrow <IOException>().And.HResult.Should().Be((int)ErrorMacros.HRESULT_FROM_WIN32(WindowsError.ERROR_FILE_EXISTS));
            }
        }
示例#3
0
        public void CopyFile(bool useCreateFile)
        {
            using (var cleaner = new TestFileCleaner())
            {
                string source      = cleaner.CreateTestFile(CompressedFile2);
                string destination = cleaner.GetTestPath();

                CompressionMethods.LzCopyFile(source, destination, false, useCreateFile).Should().Be(563);

                FileHelper.ReadAllText(destination).Should().Be(CompressedContent2);
            }
        }