public void GetLogs_DirectoryDoesNotExist_ThrowsApplicationException() { // arrange var source = new FileErrorLogSource(@"x:\invalid\directory", new FileSystemHelper(), new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver()), new FakeSettingsManager(), new FakeLog()); // act var result = Assert.Throws<ApplicationException>(() => source.GetLogs()); // assert Assert.That(result, Is.Not.Null); Assert.That(result.Message, Is.EqualTo(@"The directory: x:\invalid\directory was not found")); }
protected ErrorLogRepository CreateRepository(int maxNumberOfLogs = -1) { var fileSystemHelper = new FileSystemHelper(); var log = new FakeLog(); var settings = new FakeSettingsManager(); settings.SetMaxNumberOfLogs(maxNumberOfLogs); var parser = new ErrorLogFileParser(log, new ClientInformationResolver()); var datasource = new FileErrorLogSource(TestFilesDirectory, fileSystemHelper, parser, settings, log); var repository = new ErrorLogRepository(datasource); return repository; }
public void GetLogs_MaxNumberOfLogsIsTen_ParsesTenLatestLogsInDirectory() { // arrange var settings = new FakeSettingsManager(); settings.SetMaxNumberOfLogs(10); var source = new FileErrorLogSource(TestFilesDirectory, new FileSystemHelper(), new ErrorLogFileParser(new FakeLog(), new ClientInformationResolver()), settings, new FakeLog()); // act var result = source.GetLogs(); // assert Assert.That(result.Count, Is.EqualTo(10)); }