Esempio n. 1
0
        public void GetScreenshotFileName()
        {
            var creationDate       = new DateTime(2018, 10, 25, 5, 45, 55);
            var screenshotFileName = NamesProvider.GetScreenshotFileName(creationDate);

            Assert.AreEqual($"img_{creationDate:yyyyMMdd_HHmmssfff}.json", screenshotFileName);
        }
Esempio n. 2
0
        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 string Save(this TestScreenshotDto 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 SimpleItemInfoDto SaveScreenshot(TestScreenshotDto screenshot)
        {
            screenshot.TestScreenshotInfo.ItemName =
                NamesProvider.GetScreenshotFileName(screenshot.TestScreenshotInfo.Date);
            var testGuid = screenshot.TestGuid;
            var path     = _locationsProvider.GetScreenshotFolderPath(testGuid);

            screenshot.Save(path);
            _logger.Info($"Screenshot was saved: '{path}'");
            _logger.Debug($"Screenshot data was saved correctly: {JsonConvert.SerializeObject(screenshot, Formatting.Indented)}");
            if (_processedTests.ContainsKey(testGuid))
            {
                var testRun = _reader.GetTestRun(_processedTests[testGuid]);
                if (testRun.Screenshots.All(s => s.Date != screenshot.TestScreenshotInfo.Date))
                {
                    testRun.Screenshots.Add(screenshot.TestScreenshotInfo);
                    var output = _reader.GetTestOutput(testRun);
                    SaveTestRun(testRun, output);
                }
            }
            return(screenshot.TestScreenshotInfo);
        }