public void should_ignore_an_unchanged_file() { Context(); var packageFile = new PackageFile { Path = filePath, Checksum = "1234" }; packageFiles.Files.Add(packageFile); packageInfo.FilesSnapshot = packageFiles; var fileSystemFiles = new List<string>() { filePath }; fileSystem.Setup(x => x.get_files(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories)).Returns(fileSystemFiles); filesService.Setup(x => x.capture_package_files(It.IsAny<string>(),config)).Returns(packageFiles); because(); fileSystem.Verify(x => x.copy_file(It.IsAny<string>(),It.IsAny<string>(),It.IsAny<bool>()),Times.Never); }
public void should_backup_a_changed_file() { Context(); var packageFile = new PackageFile { Path = filePath, Checksum = "1234" }; packageFiles.Files.Add(packageFile); packageInfo.FilesSnapshot = packageFiles; var packageFileWithUpdatedChecksum = new PackageFile { Path = filePath, Checksum = "4321" }; var fileSystemFiles = new List<string>() { filePath }; fileSystem.Setup(x => x.get_files(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories)).Returns(fileSystemFiles); var updatedPackageFiles = new PackageFiles(); updatedPackageFiles.Files = new List<PackageFile>{packageFileWithUpdatedChecksum}; filesService.Setup(x => x.capture_package_files(It.IsAny<string>(), config)).Returns(updatedPackageFiles); because(); fileSystem.Verify(x => x.copy_file(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>()), Times.Once); }
public void should_remove_an_unchanged_file() { Context(); var packageFile = new PackageFile { Path = filePath, Checksum = "1234" }; packageFiles.Add(packageFile); packageInfo.FilesSnapshot.Files = packageFiles.ToList(); var fileSystemFiles = new List<string>() { filePath }; fileSystem.Setup(x => x.get_files(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories)).Returns(fileSystemFiles); filesService.Setup(x => x.get_package_file(It.IsAny<string>())).Returns(packageFile); because(); fileSystem.Verify(x => x.delete_file(filePath)); }
public void should_not_delete_an_unfound_file() { Context(); var packageFile = new PackageFile { Path = filePath, Checksum = "1234" }; var packageFileNotInOriginal = new PackageFile { Path ="c:\\files", Checksum = "4321" }; packageFiles.Add(packageFile); packageInfo.FilesSnapshot.Files = packageFiles.ToList(); var fileSystemFiles = new List<string>() { filePath }; fileSystem.Setup(x => x.get_files(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories)).Returns(fileSystemFiles); filesService.Setup(x => x.get_package_file(It.IsAny<string>())).Returns(packageFileNotInOriginal); because(); fileSystem.Verify(x => x.delete_file(filePath),Times.Never); }
public void should_do_nothing_if_the_directory_no_longer_exists() { Context(); fileSystem.ResetCalls(); fileSystem.Setup(x => x.directory_exists(It.IsAny<string>())).Returns(false); var packageFile = new PackageFile { Path = filePath, Checksum = "1234" }; packageFiles.Add(packageFile); packageInfo.FilesSnapshot.Files = packageFiles.ToList(); var fileSystemFiles = new List<string>() { filePath }; fileSystem.Setup(x => x.get_files(It.IsAny<string>(), It.IsAny<string>(), SearchOption.AllDirectories)).Returns(fileSystemFiles); filesService.Setup(x => x.get_package_file(It.IsAny<string>())).Returns(packageFile); because(); filesService.Verify(x => x.get_package_file(It.IsAny<string>()), Times.Never); fileSystem.Verify(x => x.delete_file(filePath),Times.Never); }