public void Ensure_FleetService_LoadFleet_Formats_Re() { var repo = A.Fake<IFileRepository>(); var logger = A.Fake<ILogger>(); var liines = new List<string>() { "{0}{1}".FormatLiteralArguments("1, M1, 5, 0,0,0,0,0",Constants.CaridgeReturn), "{0}{1}".FormatLiteralArguments("2, M2, 3, 1,0,0",Constants.CaridgeReturn), "{0}{1}".FormatLiteralArguments("3, M3, 5, 1,1,1,1,1",Constants.CaridgeReturn) }; var loadedFile = new StringBuilder(); liines.ForEach((line) => { loadedFile.Append(line); }); var fleetService = new FleetService(repo, logger); A.CallTo(()=>repo.LoadFile(null)).WithAnyArguments().Returns(loadedFile.ToString()); var request = new FleetRequest("Test path"); var result = fleetService.LoadFleet(request); Assert.AreEqual(result.Hosts.Count(), liines.Count); Assert.IsFalse(result.Notifications.HasErrors); }
public void Ensure_FleetService_LoadFleet_Guards_The_Result_FileName() { var repo = A.Fake<IFileRepository>(); var logger = A.Fake<ILogger>(); var fleetService = new FleetService(repo, logger); var request = new FleetRequest(null); var result = fleetService.LoadFleet(request); }
public void Ensure_FleetService_LoadFleet_LogsError_If_Loaded_File_IsNullOrEmpty() { var repo = A.Fake<IFileRepository>(); var logger = A.Fake<ILogger>(); var fleetService = new FleetService(repo, logger); A.CallTo(() => repo.LoadFile(null)).WithAnyArguments().Returns(null); var request = new FleetRequest("Test path"); var result = fleetService.LoadFleet(request); Assert.IsTrue(result.Notifications.HasErrors); A.CallTo(() => logger.Error(null)).WithAnyArguments().MustHaveHappened(); }
public FleetResult LoadFleetState(FleetRequest request) { var result = new FleetResult(); try { result = fleetService.LoadFleet(request); } catch (Exception ex) { Logger.Error(ex); result.Notifications.Add("A general service exception occured"); } return(result); }
public FleetResult LoadFleetStatus(FleetRequest request) { var result = new FleetResult(); try { result = FleetService.LoadFleet(request); } catch (Exception ex) { Logger.Error(ex); result.Notifications.Add(GeneralError); } return(result); }
static void Main() { var fleetService = new FleetServiceClient(); var hostSummaryService = new HostSummaryServiceClient(); Console.WriteLine("Loading the fellt state......"); var fleetRequest = new FleetRequest(Config.FleetStateFilePath); var fleetStatusResult = fleetService.LoadFleetState(fleetRequest); if (!fleetStatusResult.Notifications.HasErrors) { Console.WriteLine("\r\r"); Console.WriteLine("Fleet state results."); DisplayFleetStatus(fleetStatusResult); Console.WriteLine("The follow is a smmary of the fleet status"); Console.WriteLine("\r\r"); var summaryRequest = new HostSummaryRequest(Config.HostStatisticsFilePath) { Hosts = fleetStatusResult.Hosts }; var result = hostSummaryService.SummarizeHostStatistics(summaryRequest); DisplaySummary(result); } else { Console.Write("The following errors occured"); foreach (var error in fleetStatusResult.Notifications) { Console.WriteLine(error); } } Console.ReadLine(); }
public FleetResult LoadFleet(FleetRequest request) { Guardian.ArgumentNotNull(request, "request"); Guardian.ArgumentNotNull(request.FileLocation, "request.FileLocation"); var result = new FleetResult(); string[] hostEnteries = new string[0]; var fleetStateFile = Repository.LoadFile(request.FileLocation); if (fleetStateFile.IsNullOrEmpty()) { Logger.Error(ErrorMessages.FileNotFound); result.Notifications.Add(ErrorMessages.FileNotFound); } else { if (fleetStateFile.Contains("{0}{1}".FormatLiteralArguments(Constants.CaridgeReturn, Constants.NewLine))) { hostEnteries = fleetStateFile.Split("{0}{1}".FormatLiteralArguments(Constants.CaridgeReturn, Constants.NewLine).ToCharArray()); } else if (fleetStateFile.Contains(Constants.CaridgeReturn)) { hostEnteries = fleetStateFile.Split(Constants.CaridgeReturn.ToCharArray()); } else { result.Notifications.Add(ErrorMessages.IncorrectFfileState); } if (!result.Notifications.HasErrors) { hostEnteries = hostEnteries.Where(x => x.IsNotNullOrEmpty()).ToArray(); if (hostEnteries.Length == 0) { result.Notifications.Add(ErrorMessages.IncorrectFfileState); } else { var hostValidation = new HostValidation(Logger); var createdHosts = new List <HostDto>(); foreach (var host in hostEnteries) { var createdHost = hostValidation.CreateHost(host); if (createdHost.IsNotNull()) { createdHosts.Add(createdHost); } } result.Hosts = createdHosts; } } } return(result); }
public FleetRequest get_request_details(string service_ref) { var fleetRequest = new FleetRequest(); return(fleetRequest.GetRequestsDetails(service_ref)); }
public List <FleetRequest> get_for_approvals(string line_manager_id) { var fleetRequest = new FleetRequest(); return(fleetRequest.GetRequestsForApprovals(line_manager_id)); }
public List <FleetRequestData> get_approvals_data(string line_manager_id) { var fleetRequest = new FleetRequest(); return(fleetRequest.GetApprovalsData(line_manager_id)); }
public List <FleetRequest> get_fleet_requests(string level, string emp_id, string status) { var fleetRequest = new FleetRequest(); return(fleetRequest.GetFleetRequests(level, emp_id, status)); }