public List <FileInfoCollector.FileInformations> GetFileInfoLogFromPath(string path) { //TODO: unit test this var infoLines = _lfg.GetInfoLinesFromLog(path); return(_il2fi.ConvertAll(infoLines)); }
public void GetInfoLinesShouldThrowExceptionIfFileDoesntExists() { var fslMock = new Mock <IFilesystemLayer>(); fslMock.Setup(m => m.GetStringLinesOfFile(It.IsAny <string>())).Throws(new FileSystemLayerFileNotFoundException()); Mock <ILogFileNameProvider> lfnp = SetupLFNPMock(); var lfg = new LogFileGatherer(fslMock.Object, lfnp.Object); var result = lfg.GetInfoLinesFromLog("dummy"); }
public void GetInfoLinesShouldReturnEmptyListIfInputIsEmpty() { var fslMock = new Mock <IFilesystemLayer>(); fslMock.Setup(m => m.GetStringLinesOfFile(It.IsAny <string>())).Returns(new string[] {}); Mock <ILogFileNameProvider> lfnp = SetupLFNPMock(); var lfg = new LogFileGatherer(fslMock.Object, lfnp.Object); var result = lfg.GetInfoLinesFromLog("dummy"); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.IsTrue(result.Count == 0); }
public void GetInfoLinesShouldConvertInputIntoList() { var fslMock = new Mock <IFilesystemLayer>(); const string line1 = "line1"; const string line2 = "line2"; fslMock.Setup(m => m.GetStringLinesOfFile(It.IsAny <string>())).Returns(new string[] { line1, line2 }); Mock <ILogFileNameProvider> lfnp = SetupLFNPMock(); var lfg = new LogFileGatherer(fslMock.Object, lfnp.Object); var result = lfg.GetInfoLinesFromLog("dummy"); Assert.IsInstanceOfType(result, typeof(List <string>)); Assert.IsTrue(result.Count == 2); Assert.AreEqual(result[0], line1); Assert.AreEqual(result[1], line2); }