public void TestGetTransactionLogXml_ArchiveHasFile() { using (ShimsContext.Create()) { var transactionLog = new TransactionLogType(); var xml = GetXml(transactionLog); var xmlTransactionLogFileName = "transaction_log.xml"; var zipFileName = String.Format("{0}", xmlTransactionLogFileName); var entry = new System.IO.Compression.Fakes.ShimZipArchiveEntry { NameGet = () => zipFileName, Open = () => { var stream = new MemoryStream(); var writer = new StreamWriter(stream, Encoding.Unicode); writer.Write(xml); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); return(stream); } }; var entries = new List <ZipArchiveEntry>(); entries.Add(entry); var readonlyEntries = new ReadOnlyCollection <ZipArchiveEntry>(entries); var zipArchive = new System.IO.Compression.Fakes.ShimZipArchive { EntriesGet = () => readonlyEntries }; var archiveHandler = new SevisBatchZipArchiveHandler(zipArchive, xmlTransactionLogFileName); var testXml = archiveHandler.GetTransactionLogXml(); Assert.AreEqual(xml, testXml); } }
public void TestGetTransactionLogXml_ArchiveDoesNotHaveFile() { using (ShimsContext.Create()) { var transactionLog = new TransactionLogType(); var xml = GetXml(transactionLog); var xmlTransactionLogFileName = "transaction_log.xml"; var zipFileName = String.Format("{0}", xmlTransactionLogFileName); var entries = new List <ZipArchiveEntry>(); var readonlyEntries = new ReadOnlyCollection <ZipArchiveEntry>(entries); var zipArchive = new System.IO.Compression.Fakes.ShimZipArchive { EntriesGet = () => readonlyEntries }; var archiveHandler = new SevisBatchZipArchiveHandler(zipArchive, xmlTransactionLogFileName); var testXml = archiveHandler.GetTransactionLogXml(); Assert.IsNull(testXml); } }