public void TestCsvFileWriter() { AbstractWriter abstractWriter = WritersFactory.GetWriter(src.Entities.ResultWriter.File); DateTime endedAt = DateTime.Now; DateTime staetedAt = endedAt - TimeSpan.FromSeconds(25); FillWriter(ref abstractWriter, staetedAt, endedAt); string fileNameByDate = Path.Combine(PathResolver.GetAbsolutePath(), PathResolver.GetFileNameByDate(staetedAt)); string csvFile = fileNameByDate + ".csv"; string jsonFile = fileNameByDate + ".json"; string[] linesCsv = File.ReadLines(csvFile).ToArray(); int linesCsvCount = linesCsv.Length; Assert.True(Requests.Count + 1 == linesCsvCount); for (int i = 0; i < linesCsvCount; i++) { if (i == 0) { Assert.True(linesCsv[i] == "StartedAt;ResponseTime"); } else { RequestTask request = Requests[i - 1]; Assert.True($"{request.StartedAt};{request.TotalExecutionTime}" == linesCsv[i]); } } File.Delete(jsonFile); File.Delete(csvFile); }
private void FillWriter(ref AbstractWriter writer, DateTime startedAt, DateTime endedAt) { writer.SetCompletedTasks(Requests). SetEndedAtTime(endedAt) .SetStartedAtTime(startedAt) .SetStopReason(src.Entities.StopSignal.Manual); writer.Write(); }
public ChromeDriverResolver(BaseWebDriverStrategy options, WebScrapperBaseProxyEntity _proxy, string url, BaseLogger _logger) { settings = options; _l = _logger; _baseUrl = url; _d = new DirectoriesService(); _f = new FilesWriter(); _ps = _proxy; DriverDependenciesDirectory = $@"{Directory.GetCurrentDirectory()}/Scrapper/Resources/scripts/ChromeDriver/js/"; DriverResourcesDirectory = $"{Directory.GetCurrentDirectory()}/Scrapper/Resources/"; DriverBaseExtensionsPath = $"{DriverResourcesDirectory}selenium/chrome/proxy.plugin/"; }
public void TestFileWriter() { AbstractWriter abstractWriter = WritersFactory.GetWriter(src.Entities.ResultWriter.File); DateTime endedAt = DateTime.Now; DateTime staetedAt = endedAt - TimeSpan.FromSeconds(25); FillWriter(ref abstractWriter, staetedAt, endedAt); string fileNameByDate = Path.Combine(PathResolver.GetAbsolutePath(), PathResolver.GetFileNameByDate(staetedAt)); string jsonFile = fileNameByDate + ".json"; string csvFile = fileNameByDate + ".csv"; Assert.True(File.Exists(jsonFile)); Assert.True(File.Exists(csvFile)); File.Delete(jsonFile); File.Delete(csvFile); }
public void Run(RunTestDto dto) { Validate(dto); if (HaveValidationErrors()) { PrintValidationErrors(); return; } Executor.SetConfig(dto.GetTestConfig()); Executor.Configurate(); Task session = Task.Run(() => { Executor.StartTest(); }); bool manualyStopped = false; while (!session.IsCompleted) { ConsoleKeyInfo key = Console.ReadKey(); if (key.KeyChar == STOP) { Executor.StopExecution(); manualyStopped = true; break; } } List <RequestTask> result = Executor.GetResult(); if (result.Count == 0) { return; } AbstractWriter writer = WritersFactory.GetWriter(dto.ResultWriter); writer.SetCompletedTasks(result) .SetStartedAtTime(Executor.GetStartedAt()) .SetEndedAtTime(DateTime.Now) .SetStopReason(manualyStopped ? StopSignal.Manual : dto.StopSignal); writer.Write(); }
public CollectionsProcessorService(BaseLogger _logger) { _l = _logger; _f = new FilesWriter(); }
internal FilePreparator(AbstractWriter writer, AbstractWriter cloner) { this.writer = writer; this.cloner = cloner; }
public void StreamToFile(string path) { Directory.CreateDirectory(Path.GetDirectoryName(path)); AbstractWriter.StreamToFile(path, _stream); }
public LogQueue(AbstractWriter writer) { Writer = writer; }
internal XmlParser(AbstractWriter writer) { this.writer = writer; }