Exemplo n.º 1
0
        public void Copy_Should_Copy_Source_File_To_Target_Location()
        {
            // Arrange
            const string sourceFilePath = "c:\\source\\sourceFile.txt";
            const string targetFilePath = "c:\\copy\\copiedFile.txt";

            var fileSystem = CreateFileSystem();

            AddDirectoryToFileSystem(fileSystem, targetFilePath);

            var sut        = new FileCopyService(fileSystem);
            var sourceFile = fileSystem.GetFile(sourceFilePath);

            // Act
            sut.Copy(sourceFilePath, targetFilePath);

            var targetFile = fileSystem.GetFile(targetFilePath);

            // Assert
            targetFile.Should().BeEquivalentTo(sourceFile);
        }
Exemplo n.º 2
0
        public void Copy_Should_Handle_Copying_Multiple_Source_File_Types_To_Target_Location(
            string sourceFilePath,
            string embeddedResource)
        {
            // Arrange
            var targetFilePath = $"c:\\copy\\copiedFile.{Path.GetExtension(sourceFilePath)}";

            var fileSystem = CreateFileSystem();

            AddDirectoryToFileSystem(fileSystem, targetFilePath);
            AddEmbeddedResourceToFileSystem(fileSystem, sourceFilePath, embeddedResource);

            var sut        = new FileCopyService(fileSystem);
            var sourceFile = fileSystem.GetFile(sourceFilePath);

            // Act
            sut.Copy(sourceFilePath, targetFilePath);

            var targetFile = fileSystem.GetFile(targetFilePath);

            // Assert
            targetFile.Should().BeEquivalentTo(sourceFile);
        }
Exemplo n.º 3
0
        public void Copy_Should_Delete_Existing_Target_File_From_Target_Location()
        {
            // Arrange
            const string sourceFileDirectory        = "c:\\source\\sourceFile.txt";
            const string targetFileDirectory        = "c:\\copy\\copiedFile.txt";
            const string originalTargetFileContents = "Existing target file";

            var fileSystem = CreateFileSystem();

            AddDirectoryToFileSystem(fileSystem, targetFileDirectory);
            fileSystem.AddFile(targetFileDirectory, new MockFileData(originalTargetFileContents));

            var sut        = new FileCopyService(fileSystem);
            var sourceFile = fileSystem.GetFile(sourceFileDirectory);

            // Act
            sut.Copy(sourceFileDirectory, targetFileDirectory);

            var targetFile = fileSystem.GetFile(targetFileDirectory);

            // Assert
            targetFile.TextContents.Should().NotBe(originalTargetFileContents);
            targetFile.Should().BeEquivalentTo(sourceFile);
        }