public void TestDateTimeExact() { var myConfiguration = new MyLogsConfiguration(); var logs = new Logs(myConfiguration); Assert.IsTrue(DateTime.TryParseExact(logs.GetDateUtcNowString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out _), "GetDateUtcNowString doesn't returns yyyy-MM-dd HH:mm:ss format"); }
public void WriteLogLine() { var myConfiguration = new MyLogsConfiguration(); // Reset cache file File.WriteAllText(myConfiguration.FileLogWithPath, string.Empty); var logs = new Mock <Logs>(myConfiguration) { CallBase = true }; logs.Setup(t => t.GetDateUtcNowString).Returns("2000-01-01 12.12.12"); logs.Object.WriteLogLine("line1"); logs.Object.WriteLogLine("line2", LogType.Debug); logs.Object.WriteLogLine("line3", LogType.Error); logs.Object.WriteLogLine("line4", LogType.Info); logs.Object.WriteLogLine("line5", LogType.Warning); string allLogs = logs.Object.GetLogs(); Assert.AreEqual(allLogs, File.ReadAllText("Fixtures/LogsTest1.txt")); File.WriteAllText(myConfiguration.FileLogWithPath, string.Empty); }
public void TestDateTime() { var myConfiguration = new MyLogsConfiguration(); var logs = new Logs(myConfiguration); string dt = logs.GetDateUtcNowString; Regex regex = new Regex(@"^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$"); Match match = regex.Match(dt); Assert.IsTrue(match.Success, $"Expected date format: yyyy-MM-dd HH:mm:ss but property returns: {dt}"); }
public void TestDateTimeValue(int year, int month, int day, int hour, int minute, int second, string dtCompare) { var dt = new DateTime(year, month, day, hour, minute, second); var myConfiguration = new MyLogsConfiguration(); var logs = new Mock <Logs>(myConfiguration) { CallBase = true }; logs.Setup(t => t.GetDateUtc).Returns(dt); Assert.AreEqual(logs.Object.GetDateUtcNowString, dtCompare); }