public void should_save_if_the_snapshot_is_not_null()
            {
                Context();
                files = new PackageFiles();
                
                because();

                XmlService.Verify(x => x.serialize(files, It.IsAny<string>()), Times.Once());
            }
 public override void Context()
 {
     base.Context();
     package.Setup(x => x.Id).Returns("bob");
     packageInfo = new ChocolateyPackageInformation(package.Object);
     packageInfo.FilesSnapshot = new PackageFiles();
     packageFiles = new PackageFiles();
     fileSystem.Setup(x => x.directory_exists(It.IsAny<string>())).Returns(true);
 }
            public void should_not_do_anything_if_the_snapshot_is_null()
            {
                Context();
                files = null;

                because();

                XmlService.Verify(x => x.serialize(files, It.IsAny<string>()), Times.Never);
            }
 public override void Because()
 {
     result = Service.capture_package_files(packageResult, config);
 }
            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);
            }