public Log ( |
||
exception | ||
Результат | void |
public void Log_CreatesBackupFile() { Logger logger = new Logger(config, 2); logger.Log(new String('T', backupSize)); String expected = "Account: 2" + Environment.NewLine + "Message: " + new String('T', backupSize) + Environment.NewLine + Environment.NewLine; String actual = File.ReadAllText(Path.Combine(logPath, $"Log {DateTime.Now.ToString("yyyy-MM-dd HHmmss")}.txt")); Assert.True(actual.StartsWith("Time :")); Assert.True(actual.EndsWith(expected)); }
public void Log_CreatesBackupFile() { Logger logger = new Logger(2); logger.Log(new String('T', backupSize)); String expected = "Account: 2" + Environment.NewLine + "Message: " + new String('T', backupSize) + Environment.NewLine + Environment.NewLine; String actual = File.ReadAllText(Directory.GetFiles(logDirectory, "Log *.txt").Single()); Assert.True(actual.StartsWith("Time :")); Assert.True(actual.EndsWith(expected)); }
public void Log_LogsMessage() { Logger logger = new Logger(config); logger.Log("Test"); String expected = "Account: " + Environment.NewLine + "Message: Test" + Environment.NewLine + Environment.NewLine; String actual = File.ReadAllText(log); Assert.True(actual.StartsWith("Time :")); Assert.True(actual.EndsWith(expected)); }
public void Log_MessageForCurrentAccount() { HttpContext.Current = HttpContextFactory.CreateHttpContext(); Logger logger = new Logger(); logger.Log("Test"); String expected = "Account: 1" + Environment.NewLine + "Message: Test" + Environment.NewLine + Environment.NewLine; String actual = File.ReadAllText(logPath); Assert.True(actual.StartsWith("Time :")); Assert.True(actual.EndsWith(expected)); }
public void Log_InnerException() { Exception exception = new Exception("", Substitute.ForPartsOf<Exception>()); exception.InnerException.StackTrace.Returns("StackTrace"); exception.InnerException.Message.Returns("Message"); Logger logger = new Logger(config, 2); logger.Log(exception); String actual = File.ReadAllText(log); String expected = String.Format("Account: 2{0}Message: {1}: {2}{0}{3}{0}{0}", Environment.NewLine, exception.InnerException.GetType(), exception.InnerException.Message, exception.InnerException.StackTrace); Assert.True(actual.StartsWith("Time :")); Assert.True(actual.EndsWith(expected)); }