public void Extract() { string actualUnPackedDirectory = zipBundleReader.Extract(); zipReaderMock.Verify(z => z.UnPack()); Assert.AreEqual(unPackDirectory, actualUnPackedDirectory); }
public void Read_Report_ChecksumMismatch() { var logger = new MockLogger(); var zipReader = kernel.Get <IZipFileReaderWrapper>(); var checkSumGen = kernel.Get <ICheckSumGenerator>(); var fileSystem = kernel.Get <IFileSystem>(); var serializeWrapper = kernel.Get <ISerializeWrapper>(); string zipFile = Path.Combine(GetTestDataPath(), "InvalidChecksum.zip"); var actualReader = new ZipBundleReader( zipFile, unpackDir, zipReader, checkSumGen, logger, fileSystem, serializeWrapper); string actualUnPackDir = actualReader.Extract(); // This is the file on disk that has an invalid checksum string expectedFailedFilename = Path.Combine(actualUnPackDir, "Export\\SSRSMigrate_AW_Tests\\Reports\\Company Sales.rdl"); string expectedFailedChecksum = "BAD CHECKSUM HERE"; // Set expected values int expectedSuccessful = 2; int expectedFailed = 1; // Actual values int actualSuccessful = 0; int actualFailed = 0; string actualFailedFilename = null; string actualFailedChecksum = null; string actualFailedPath = null; actualReader.OnReportRead += delegate(IBundleReader sender, ItemReadEvent e) { if (e.Success) { actualSuccessful++; } else { actualFailed++; actualFailedPath = e.Path; actualFailedFilename = e.FileName; actualFailedChecksum = e.CheckSum; } }; actualReader.ReadExportSummary(); actualReader.Read(); Assert.AreEqual(expectedSuccessful, actualSuccessful); Assert.AreEqual(expectedFailed, actualFailed); Assert.AreEqual(expectedFailedChecksum, actualFailedChecksum); Assert.AreEqual(expectedFailedFilename, actualFailedFilename); }
public void Read_DirectoryDoesntExist() { var logger = new MockLogger(); var zipReader = kernel.Get <IZipFileReaderWrapper>(); var checkSumGen = kernel.Get <ICheckSumGenerator>(); var fileSystem = kernel.Get <IFileSystem>(); var serializeWrapper = kernel.Get <ISerializeWrapper>(); string zipFile = Path.Combine(GetTestDataPath(), zipFilename); var actualReader = new ZipBundleReader( zipFile, unpackDir, zipReader, checkSumGen, logger, fileSystem, serializeWrapper); string actualUnPackDir = actualReader.Extract(); // This is the directory to delete on disk to simulate a folder not extracted string expectedFailedFolderName = Path.Combine(actualUnPackDir, "Export\\SSRSMigrate_AW_Tests\\Reports\\Sub Folder"); // Delete this directory from the extraction directory, for the purpose of testing for a folder that does not exist Directory.Delete(expectedFailedFolderName, true); // Set expected values int expectedSuccessfulFolders = 2; int expectedFailedFolders = 1; int actualSuccessfulFolders = 0; int actualFailedFolders = 0; string actualFailedFoldersName = null; actualReader.OnFolderRead += delegate(IBundleReader sender, ItemReadEvent e) { if (e.Success) { actualSuccessfulFolders++; } else { actualFailedFolders++; actualFailedFoldersName = e.FileName; } }; actualReader.ReadExportSummary(); actualReader.Read(); Assert.AreEqual(expectedSuccessfulFolders, actualSuccessfulFolders, "Successful Folders"); Assert.AreEqual(expectedFailedFolders, actualFailedFolders, "Failed Folders"); Assert.AreEqual(expectedFailedFolderName, actualFailedFoldersName, "Folders Name"); }