public void AddLogLine(LogLine logLine) { try { _curDate = _dHelper.DateCheckAndCreateFile(_curDate, logLine.Timestamp); _dHelper.AddLineToFile(logLine); } catch (Exception e) { _dHelper.AddLineToFile(new LogLine() { Text = e.ToString(), Timestamp = DateTime.Now }); } }
public void AddLineToFile_LogLineIsSet_StringFormat() { //Arrange var dh = new DocumentHelper(_testDirectory); dh.CreateDirectory(); dh.CreateFile(DateTime.Now); LogLine logLine = new LogLine(); // Act Action act = () => dh.AddLineToFile(logLine); // Assert act.ShouldNotThrow(); }
public void AddLineToFile_LogLineIsNull_ThrowsNullReferenceException() { // Arrange var dh = new DocumentHelper(_testDirectory); dh.CreateDirectory(); dh.CreateFile(DateTime.Now); LogLine logLine = null; // Act Action act = () => dh.AddLineToFile(logLine); // Assert act.ShouldThrow <NullReferenceException>(); }