コード例 #1
0
ファイル: SessionLogTest.cs プロジェクト: ZHJEE/OpenTAP
        public void RenameSessionLogFile()
        {
            Log.Flush();

            var currentName = SessionLogs.GetSessionLogFilePath();

            SessionLogs.Rename("Log1.txt");
            SessionLogs.Rename("LogTest/Log2.txt");
            string inlog = "This is written to log2";

            log.Debug(inlog);
            Log.Flush();
            SessionLogs.Flush();
            var file = File.Open("LogTest/Log2.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            using (var reader = new StreamReader(file))
            {
                var part = reader.ReadToEnd();
                StringAssert.Contains(inlog, part);
            }

            Assert.AreEqual(Path.GetFullPath(SessionLogs.GetSessionLogFilePath()), Path.GetFullPath("LogTest/Log2.txt"));
            SessionLogs.Rename(currentName);
            Assert.AreEqual(currentName, SessionLogs.GetSessionLogFilePath());
            Assert.IsFalse(File.Exists("Log1.txt"));
            Assert.IsFalse(File.Exists("LogTest/Log2.txt"));
            Assert.IsTrue(Directory.Exists("LogTest"));
        }
コード例 #2
0
 public static void AssemblyCleanup()
 {
     SessionLogs.Flush();
     Log.Flush();
 }