public void ReadErrorLogFileThrowsException() { var mockFile = Mock.Of <File>(); Mock.Get(mockFile).Setup(file => file.ReadAllText()).Throws(new System.IO.IOException()); Assert.IsNull(ErrorLogHelper.ReadErrorLogFile(mockFile)); }
public void ReadErrorLogFile() { var errorLog = new ManagedErrorLog { Id = Guid.NewGuid(), ProcessId = 123 }; var serializedErrorLog = LogSerializer.Serialize(errorLog); var mockFile = Mock.Of <File>(); Mock.Get(mockFile).Setup(file => file.ReadAllText()).Returns(serializedErrorLog); var actualContents = ErrorLogHelper.ReadErrorLogFile(mockFile); Assert.AreEqual(errorLog.Id, actualContents.Id); Assert.AreEqual(errorLog.ProcessId, actualContents.ProcessId); }