public FileProcessed GenerateFileProcessed(string filePath) { if (string.IsNullOrEmpty(filePath)) { throw new ArgumentException("FilePath is a required field, please, fill it."); } _logger.Info($"Starting to generate a fileProcessed of '{filePath}'"); var fileProcessed = new FileProcessed { FilePath = filePath, FileName = Path.GetFileName(filePath), Dictionary = _fileProcessor.CountWordsOfFile(filePath) }; _logger.Info($"Finish to generate a fileProcessed of '{filePath}' with name={fileProcessed.FileName}"); return(fileProcessed); }
public void Given_GenerateFileProcessed_getsFilePath_returnsAFileProcessed() { var filePath = "C:\\folder\\filePath.txt"; var fileName = "filePath.txt"; A.CallTo(() => _fakeFileProcessor.CountWordsOfFile(filePath)).Returns(_dictionary); var response = _fileManager.GenerateFileProcessed(filePath); Assert.IsNotNull(response); Assert.IsTrue(response.FileName == fileName); Assert.IsTrue(response.FilePath == filePath); Assert.IsTrue(response.Dictionary.Count == 4); Assert.IsTrue(response.Dictionary.ContainsKey("this")); Assert.IsTrue(response.Dictionary["this"] == 1); Assert.IsTrue(response.Dictionary.ContainsKey("is")); Assert.IsTrue(response.Dictionary["is"] == 2); Assert.IsTrue(response.Dictionary.ContainsKey("a")); Assert.IsTrue(response.Dictionary["a"] == 3); Assert.IsTrue(response.Dictionary.ContainsKey("test")); Assert.IsTrue(response.Dictionary["test"] == 1); }
public void Given_CountWordsOfFile_throwsExceptionWithNullPath() { _fileProcessor.CountWordsOfFile(null); }