public void CopyFileTest() { TestUtility.TestProlog(new string[] { "-output", TestUtility.TestDirectory + "\\myOutput", "-mode", "collect" }); string traceLogPath = Utility.GenerateProgramFilePath(Program.Config.WorkingDirectoryPath, ".log"); using (TraceLogger traceLogger = new TraceLogger(traceLogPath)) { using (LogPackage logPackage = new LogPackage(Program.Config.OutputDirectoryPath, traceLogger)) { foreach (KeyValuePair <string, string> log in TestUtility.ExistingTestLogs) { Assert.IsTrue(logPackage.AddFile(string.Format("{0}/{1}", log.Key, log.Value), Path.Combine(TestUtility.TestDirectory, log.Value), true)); } } } string zipFilePath = Directory.GetFiles(Program.Config.OutputDirectoryPath, "*.zip", SearchOption.TopDirectoryOnly).First(); Assert.IsTrue(File.Exists(zipFilePath)); foreach (string fileName in TestUtility.ExistingTestLogs.Values) { Assert.IsTrue(Directory.GetFiles(Program.Config.OutputDirectoryPath, fileName, SearchOption.AllDirectories).Any()); } File.Delete(traceLogPath); TestUtility.TestEpilog(); }
public void PackageFileTest() { TestUtility.TestProlog(); string traceLogPath = Utility.GenerateProgramFilePath(Program.Config.WorkingDirectoryPath, ".log"); using (TraceLogger traceLogger = new TraceLogger(traceLogPath)) { using (LogPackage logPackage = new LogPackage(Program.Config.OutputDirectoryPath, traceLogger)) { foreach (KeyValuePair <string, string> log in TestUtility.ExistingTestLogs) { Assert.IsTrue(logPackage.AddFile(string.Format("{0}/{1}", log.Key, log.Value), Path.Combine(TestUtility.TestDirectory, log.Value), false)); } } } string extractedDirectory = Program.Config.WorkingDirectoryPath + "\\extracted"; string zipFilePath = Directory.GetFiles(Program.Config.OutputDirectoryPath, "*.zip", SearchOption.TopDirectoryOnly).First(); ZipFile.ExtractToDirectory(zipFilePath, extractedDirectory); foreach (string fileName in TestUtility.ExistingTestLogs.Values) { Assert.IsTrue(Directory.GetFiles(extractedDirectory, fileName, SearchOption.AllDirectories).Any()); } Directory.Delete(extractedDirectory, recursive: true); File.Delete(traceLogPath); TestUtility.TestEpilog(); }
public void UploadTest() { TestUtility.TestProlog(); string traceLogPath = Utility.GenerateProgramFilePath(Program.Config.WorkingDirectoryPath, ".log"); using (TraceLogger traceLogger = new TraceLogger(traceLogPath)) { using (LogPackage logPackage = new LogPackage(Program.Config.OutputDirectoryPath, traceLogger)) { foreach (KeyValuePair <string, string> log in TestUtility.ExistingTestLogs) { Assert.IsTrue(logPackage.AddFile(string.Format("{0}/{1}", log.Key, log.Value), Path.Combine(TestUtility.TestDirectory, log.Value), true)); } BlobLogUploaderTest uploader = new BlobLogUploaderTest(traceLogger); uploader.UploadAsync(logPackage, TestUtility.GetAzureCredential()).Wait(); Assert.AreEqual(4, uploader.fileUploaded); } } File.Delete(traceLogPath); TestUtility.TestEpilog(); }