public static ITestRun SaveScreenshot(this ITestRun testRun, byte[] screenBytes, string reportOutputPath) { var screenPath = Path.Combine(reportOutputPath, Paths.Folders.Tests, testRun.TestInfo.Guid.ToString(), Paths.Folders.Img); var screenshotName = ScreenshotHelper.SaveScreenshot(screenPath, screenBytes, DateTime.Now); var screenshot = new TestScreenshot(screenshotName); testRun.Screenshots.Add(screenshot); return(testRun); }
public static TestScreenshotDto ToDto(this TestScreenshot testScreenshot) { var testScreenshotDto = new TestScreenshotDto { TestScreenshotInfo = testScreenshot.TestScreenshotInfo.ToDto(), Base64Data = testScreenshot.Base64Data, TestGuid = testScreenshot.TestGuid, Format = testScreenshot.Format }; return(testScreenshotDto); }
public static TestScreenshot Map(this TestScreenshotDto testScreenshotDto) { var name = NamesProvider.GetScreenshotFileName(testScreenshotDto.TestScreenshotInfo.Date); var testScreenshot = new TestScreenshot { TestScreenshotInfo = testScreenshotDto.TestScreenshotInfo.MapSimpleItemInfo(name), Base64Data = testScreenshotDto.Base64Data, TestGuid = testScreenshotDto.TestGuid, Format = testScreenshotDto.Format }; return(testScreenshot); }
public static ITestRun TakeScreenshot(this ITestRun testRun, string testPath, bool takeScreenshotAfterFail) { if (!takeScreenshotAfterFail || !testRun.FailedOrBroken) { return(testRun); } var date = DateTime.Now; var s = new TestScreenshot(date); Taker.TakeScreenshot(Path.Combine(testPath, "img"), date); testRun.Screenshots.Add(s); return(testRun); }
public void SaveScreenshot(Bitmap screen) { _action.Safe(() => { var testGuid = _currentTestRun.TestInfo.Guid.ToString(); var date = DateTime.Now; var s = new TestScreenshot(date); ScreenshotHelper.SaveScreenshot(Path.Combine(TestsPath, testGuid, Paths.Folders.Img), screen, date); _currentTestRun.Screenshots.Add(s); _currentTestRuns.First( tr => tr.TestInfo.Guid.Equals(_currentTestRun.TestInfo.Guid)) .Screenshots.Add(s); }); }
public static TestScreenshot LoadTestScreenshot(this string fullPath) { TestScreenshot testScreenshot = null; if (File.Exists(fullPath)) { using (var file = File.OpenText(fullPath)) { var serializer = new JsonSerializer(); testScreenshot = (TestScreenshot)serializer.Deserialize(file, typeof(TestScreenshot)); } } return(testScreenshot); }
public static string Save(this TestScreenshot testScreenshot, string path) { path.Create(); var fullPath = Path.Combine(path, NamesProvider.GetScreenshotFileName(testScreenshot.TestScreenshotInfo.Date)); using (var file = File.CreateText(fullPath)) { var serializer = new JsonSerializer(); serializer.Serialize(file, testScreenshot); } var fileInfo = new FileInfo(fullPath); fileInfo.Refresh(); fileInfo.CreationTime = testScreenshot.TestScreenshotInfo.Date; return(fullPath); }
public void SaveScreenshot(Bitmap screen) { lock (_lock) { _actionHelper.SafeAction(() => { var testGuid = _currentTestRun.TestInfo.Guid.ToString(); var date = DateTime.Now; var s = new TestScreenshot(date); Taker.SaveScreenshot(Path.Combine(TestsPath, testGuid, "img"), screen, date); _currentTestRun.Screenshots.Add(s); _currentTestRuns.First( tr => tr.TestInfo.Guid.Equals(_currentTestRun.TestInfo.Guid)) .Screenshots.Add(s); }); } }
public static DatabaseEntity <TestScreenshot> Map(this TestScreenshotDto testScreenshotDto) { var id = $"screenshot-{testScreenshotDto.TestGuid.ToString()}" + $"-{testScreenshotDto.TestScreenshotInfo.Date:yyyyMMdd_HHmmssfff}"; var testScreenshot = new TestScreenshot { TestScreenshotInfo = testScreenshotDto.TestScreenshotInfo.MapSimpleItemInfo(id), Base64Data = testScreenshotDto.Base64Data, TestGuid = testScreenshotDto.TestGuid, Format = testScreenshotDto.Format }; var entity = new DatabaseEntity <TestScreenshot> { Data = testScreenshot, Id = id, Type = EntityType.ScreenshotType }; return(entity); }