Exemple #1
0
        private ScreenshotFileInfoDto GenerateFileInfo(StepResult stepResult)
        {
            Step step = stepResult.Parent as Step;

            if (step == null)
            {
                throw new InvalidOperationException();
            }
            int stepResultNum = step.Results.IndexOf(stepResult);

            if (stepResultNum < 0)
            {
                throw new InvalidOperationException();
            }
            int          stepNum         = step.Number;
            Verification verification    = step.Parent as Verification;
            int          verificationNum = verification.Number;
            var          dto             = new ScreenshotFileInfoDto(
                string.Format(@"Verification-{0}\", verificationNum.ToString("D2")),
                null);

            foreach (Result possiblyResult in Enum.GetValues(typeof(Result)))
            {
                string postfix;
                switch (possiblyResult)
                {
                case Result.Failed:
                    postfix = "Failed";
                    break;

                case Result.Passed:
                    postfix = "Passed";
                    break;

                default:
                    postfix = "";
                    break;
                }
                string possiblyFileName = CutForFileName(string.Format(
                                                             "Step {0}-{1}{2}",
                                                             stepNum,
                                                             step.Results.Count > 1 ? (stepResultNum + 1).ToString("D2") + "-" : "",
                                                             stepResult.Text)) +
                                          (postfix == "" ? "" : "-" + postfix);
                if (possiblyResult == stepResult.Result)
                {
                    dto.FileName = possiblyFileName;
                }
                else
                {
                    dto.AddPossiblyFileName(possiblyFileName);
                }
            }

            return(dto);
        }
Exemple #2
0
        private FileInfoDto GetFileInfoDtoAndDeleteExistingFiles(string rootFolder)
        {
            ScreenshotFileInfoDto screenshotFileInfoDto = Parent.GenerateFileInfoForTestCaseItem(
                new TestCaseItemInfoDto {
                Item = this, RootFolder = rootFolder, ImageFormat = ScreenshotMaker.ImageFormat
            });

            foreach (string possiblyFileName in screenshotFileInfoDto.GetPossiblyFileNames())
            {
                ScreenshotMaker.RemoveScreenshot(new FileInfoDto(screenshotFileInfoDto.Path, possiblyFileName));
            }
            return(new FileInfoDto(screenshotFileInfoDto.Path, screenshotFileInfoDto.FileName));
        }
Exemple #3
0
        private ScreenshotFileInfoDto GenerateFileInfo(Setup setup)
        {
            int setupNum = Setups.IndexOf(setup);

            if (setupNum < 0)
            {
                throw new InvalidOperationException();
            }
            var dto = new ScreenshotFileInfoDto(
                @"Setup\",
                CutForFileName(string.Format("{0}-{1}", (setupNum + 1).ToString("D2"), setup.Text)));

            return(dto);
        }
Exemple #4
0
        public ScreenshotFileInfoDto GenerateFileInfoForTestCaseItem(TestCaseItemInfoDto itemInfoDto)
        {
            string targetFolder = GetTargetFolderPath(itemInfoDto.RootFolder);
            ScreenshotFileInfoDto screenshotFileInfoDto = GenerateFileInfo(itemInfoDto.Item);

            screenshotFileInfoDto.Path = Path.Combine(
                targetFolder,
                PathCleaner.GetPathWithoutInvalidChars(screenshotFileInfoDto.Path));

            screenshotFileInfoDto.TransformFileNames(
                s =>
            {
                string result = PathCleaner.GetFileNameWithoutInvalidChars(s);
                result       += "." + itemInfoDto.ImageFormat.ToString().ToLower();
                return(result);
            }
                );

            return(screenshotFileInfoDto);
        }
Exemple #5
0
        private ScreenshotFileInfoDto GenerateFileInfo(Data data)
        {
            Verification verification = data.Parent as Verification;

            if (verification == null)
            {
                throw new InvalidOperationException();
            }
            int verificationNum = verification.Number;
            int dataNum         = verification.Data.IndexOf(data);

            if (dataNum < 0)
            {
                throw new InvalidOperationException();
            }
            var dto = new ScreenshotFileInfoDto(
                string.Format(@"Verification-{0}\", verificationNum.ToString("D2")),
                CutForFileName(string.Format("Data-{0}-{1}", (dataNum + 1).ToString("D2"), data.Text)));

            return(dto);
        }