public void import_should_persist_data_to_the_repository() { // Arrange string[] args = { "--import" }; var server1 = CreateFakeServer("JabberWocky1"); var environment = new Environment(); environment.Name = "PRODUCTION"; environment.Servers.Add(server1); var config = new ConfigurationMock(); config.Environments.Add(environment); var repository = new RepositoryMock(); var runner = new Runner(config, repository); // Act runner.Run(args); // Assert string output = _consoleWriter.ToString(); Assert.That(output, Is.StringContaining("Finished.")); Assert.That(repository.LogEntries.Count, Is.EqualTo(FULL_LOG_ROW_COUNT)); }
public void environment_arg_should_scan_a_single_environment() { // Arrange string[] args = { "--environment=DEV", "--import" }; var server1 = CreateFakeServer("JabberWocky1"); var server2 = CreateFakeServer("JabberWocky2"); var environmentProd = new Environment(); environmentProd.Name = "PRODUCTION"; environmentProd.Servers.Add(server1); var environmentDev = new Environment(); environmentDev.Name = "DEV"; environmentDev.Servers.Add(server1); environmentDev.Servers.Add(server2); var config = new ConfigurationMock(); config.Environments.Add(environmentProd); config.Environments.Add(environmentDev); var repository = new RepositoryMock(); var runner = new Runner(config, repository); // Act runner.Run(args); // Assert string output = _consoleWriter.ToString(); Assert.That(output, Is.StringContaining("Finished.")); Assert.That(repository.LogEntries.Count, Is.EqualTo(FULL_LOG_ROW_COUNT * 2)); }
private ServerLogFileContainer CreateContainer(string logPath) { var server = new Server() { CopyFilesToLocal = true, Name = "server", Username = "******", Password = "******", Path = "" }; var environment = new Environment() { Name = "environment" }; environment.Servers.Add(server); var appLogFiles = new List<AppLogFiles>(); appLogFiles.Add(new AppLogFiles() { LogfilePaths = { logPath }, Appname = APP_NAME }); var container = new ServerLogFileContainer(); container.Environment = environment; container.Server = server; container.AppLogFiles = appLogFiles; return container; }
private List<ServerViewModel> GetDashboardData(Environment environment) { var list = new List<ServerViewModel>(); foreach (string applicationName in _configuration.Applications.OrderBy(x => x)) { List<LogEntry> entries = _repository.GetEntriesSince(environment.Name, applicationName, _configuration.MaxAgeDays).ToList(); var topException = entries.GroupBy(x => x.ExceptionType) .OrderByDescending(x => x.Count()); string exceptionType = ""; var topItem = topException.FirstOrDefault(); if (topItem != null) exceptionType = topItem.Key; var model = new ServerViewModel() { Application = applicationName, TopExceptionType = exceptionType, ErrorCount = entries.Count, ErrorCountPerServer = entries.Count / environment.Servers.Count(), ServerCount = environment.Servers.Count() }; list.Add(model); } return list; }