public void GetLastLogFileName_EmptyFolder()
 {
     using (TempDirectory tempDir = new TempDirectory())
     {
         Assert.IsNull(LogFileUtil.GetLatestLogFileName(tempDir.ToString()));
     }
 }
 public void GetLastBuildDate_NoFiles()
 {
     using (TempDirectory tempDir = new TempDirectory())
     {
         Assert.AreEqual(new DateTime(), LogFileUtil.GetLastBuildDate(tempDir.ToString(), new DateTime()));
     }
 }
Exemple #3
0
        //void OnCubeDestroyed(CubeDestroyEvent e)
        //{
        //    if (LogCubes == false) return;
        //    string cubePosition = e.Position.x + "," + e.Position.y + "," + e.Position.z;

        //    string str = "";

        //    str = str + "A cube has been destroyed at [" + cubePosition + "].";

        //    Log("Cubes", str);
        //}

        void Log(string file, string msg)
        {
            string filepath = file + ".log";
            string text     = DateTime.Now.ToString("d/M/yyyy") + " " + DateTime.Now.ToString("HH:mm:ss") + " " + file + ": " + msg + "\r\n";

            LogFileUtil.LogTextToFile("scriptfiles/logs", filepath, text);
        }
        public void CreateUrl_FailedBuild()
        {
            string expected = "?log=log20020222120000.xml";
            string actual   = LogFileUtil.CreateUrl(CreateIntegrationResult(IntegrationStatus.Failure, new DateTime(2002, 02, 22, 12, 00, 00)));

            Assert.AreEqual(expected, actual);
        }
        public void CreateUrlWithGivenFilenameAndProjectName()
        {
            string filename = "log20020222120000Lbuild.0.xml";
            string expected = "?log=log20020222120000Lbuild.0.xml&project=myproject";
            string actual   = LogFileUtil.CreateUrl(filename, "myproject");

            Assert.AreEqual(expected, actual);
        }
        public void CreateUrl_givenFilename()
        {
            string filename = "log20020222120000Lbuild.0.xml";
            string expected = "?log=log20020222120000Lbuild.0.xml";
            string actual   = LogFileUtil.CreateUrl(filename);

            Assert.AreEqual(expected, actual);
        }
 public void GetLastLogFileName()
 {
     string[] testFilenames = { "log123.xml",                    "log200.xml", "logfile.txt",
                                "log20010830164057Lbuild.6.xml",
                                "log20011230164057Lbuild.8.xml",
                                "log20010430164057Lbuild.7.xml",
                                "badfile.xml" };
     using (TempDirectory tempPath = new TempDirectory())
     {
         CreateTempFiles(tempPath, testFilenames);
         string logfile = LogFileUtil.GetLatestLogFileName(tempPath.ToString());
         Assert.AreEqual("log20011230164057Lbuild.8.xml", logfile);
     }
 }
 public void GetLastBuildDate()
 {
     string[] testFilenames = { "log123.xml",                    "log200.xml", "logfile.txt",
                                "log20010830164057Lbuild.6.xml",
                                "log20011230164057Lbuild.6.xml",
                                "log20010430164057Lbuild.6.xml",
                                "badfile.xml" };
     using (TempDirectory tempPath = new TempDirectory())
     {
         CreateTempFiles(tempPath, testFilenames);
         DateTime expected = new DateTime(2001, 12, 30, 16, 40, 57);
         DateTime actual   = LogFileUtil.GetLastBuildDate(tempPath.ToString(), new DateTime());
         Assert.AreEqual(expected, actual);
     }
 }
        public void ListFiles()
        {
            // testFilenames array must be in sorted order -- otherwise links iteration will fail
            string[] testFilenames = { "log123.xml",                    "log200.xml", "logfile.txt",
                                       "log20020830164057Lbuild.6.xml", "badfile.xml" };

            using (TempDirectory tempPath = new TempDirectory())
            {
                CreateTempFiles(tempPath, testFilenames);
                string[] fileNames = LogFileUtil.GetLogFileNames(tempPath.ToString());
                Assert.AreEqual(3, fileNames.Length);
                Assert.AreEqual(testFilenames[0], fileNames[0]);
                Assert.AreEqual(testFilenames[1], fileNames[1]);
            }
        }
        public void GetLatestBuildNumber()
        {
            string[] filenames = new string[] {
                "log19710514150000.xml",
                "log19710514150001.xml",
                "log20020830164057Lbuild.9.xml",
                "log19710514150002.xml",
                "log20020830164057Lbuild.7.xml",
                "log19710514150003.xml",
                "log20020830164057Lbuild.6.xml",
                "log20020830164057Lbuild.8.xml",
                "log19710514150004.xml"
            };
            int actual = LogFileUtil.GetLatestBuildNumber(filenames);

            Assert.AreEqual(9, actual);
        }
Exemple #11
0
 private static void Log(string type, string msg) => LogFileUtil.LogTextToFile($"..\\Saves\\oxide\\logs\\{type}_{DateTime.Now.ToString("dd-MM-yyyy")}.txt", $"[{DateTime.Now.ToString("h:mm:ss tt")}] {msg}\r\n");
Exemple #12
0
 private void Log(string msg, string fileName) => LogFileUtil.LogTextToFile($"..\\oxide\\logs\\AT-{fileName}_{DateTime.Now:yyyy-MM-dd}.txt", $"[{DateTime.Now:h:mm:ss tt}] {msg}\r\n");
        public void GetLastLogFileName_UnknownPath()
        {
            string logfile = LogFileUtil.GetLatestLogFileName(@"c:\non\exi\stent");

            Assert.IsNull(logfile);
        }
 public void GetLastBuildDate_NoDirectory()
 {
     Assert.AreEqual(new DateTime(), LogFileUtil.GetLastBuildDate(@"c:\non\exi\stent", new DateTime()));
 }
        public void GetLatestBuildNumberHandlesString()
        {
            int actual = LogFileUtil.GetLatestBuildNumber(new string[] { "log20020830164057Lbuild.v1.1.8.xml" });

            Assert.AreEqual(118, actual);
        }
 public void GetLatestBuildNumberWithMissingPath()
 {
     Assert.AreEqual(0, LogFileUtil.GetLatestBuildNumber(@"c:\non\exi\stent"));
 }
Exemple #17
0
 private void Log(string msg) => LogFileUtil.LogTextToFile($"..\\oxide\\logs\\TimeLevel_{DateTime.Now:yyyy-MM-dd}.txt", $"[{DateTime.Now:h:mm:ss tt}] {msg}\r\n");