public ActionResult View(string filename, int pageNumber = 1, int noOfResults = 20)
        {
            pageNumber = pageNumber < 1 ? 1 : pageNumber;
            TestFile           testFile = _testsClient.GetTestFile(filename);
            IEnumerable <Test> tests    = testFile.Tests.GetPaged(noOfResults, pageNumber);

            var viewModel = new TestFileViewModel
            {
                PageNumbers  = testFile.Tests.GetPageNumbersToShow(noOfResults),
                Tests        = _testFileMapper.BuildTests(tests, pageNumber, noOfResults),
                Filename     = filename,
                PageNumber   = pageNumber,
                NoOfResults  = noOfResults,
                Environments = _environmentsService.Get().OrderBy(x => x.Order).ThenBy(x => x.Name).Select(x => x.Name).ToArray()
            };

            string viewName = "View";

            if (_configuration.ReadonlyMode)
            {
                viewName = "View-ReadonlyMode";
            }

            return(View(viewName, viewModel));
        }
        public async Task <ActionResult> Index(int pageNumber = 1, int noOfResults = 20, string environment = "")
        {
            ViewBag.Title = string.IsNullOrEmpty(environment) ? "All" : environment;

            TestFileResultSummaryCollection result = await _testsClient.GetSummaries(DateTime.Today.AddYears(-1), pageNumber, noOfResults, environment);

            result.Environments = _environmentsService.Get().OrderBy(x => x.Order).ThenBy(x => x.Name).Select(x => x.Name).ToArray();
            result.Environment  = environment;
            return(View("Index", result));
        }
Beispiel #3
0
        public ActionResult Index(int pageNumber = 1, int noOfResults = 10)
        {
            RunHealthChecks();
            ViewBag.Title = "All test files";

            IEnumerable <string> files = _testsClient.ListFiles().ToList();

            var model = new IndexViewModel
            {
                PageNumber   = pageNumber,
                NoOfResults  = noOfResults,
                PageNumbers  = files.GetPageNumbersToShow(noOfResults),
                Files        = files.GetPaged(noOfResults, pageNumber),
                Environments = _environmentsService.Get().OrderBy(x => x.Order).ThenBy(x => x.Name).Select(x => x.Name).ToArray()
            };

            string viewName = "Index";

            if (_configuration.ReadonlyMode)
            {
                viewName = "Index-ReadonlyMode";
            }

            return(View(viewName, model));
        }
Beispiel #4
0
        public TestViewModel BuildTestViewModel(TestFile testFile, int position, int pageNo = 1)
        {
            if (testFile == null)
            {
                throw new ArgumentNullException(nameof(testFile));
            }

            Test test = testFile.Tests.Skip(position).First();

            MethodType methodType;

            if (!Enum.TryParse(test.Method, true, out methodType))
            {
                methodType = MethodType.GET;
            }

            var model = new TestViewModel
            {
                Position = position,
                Filename = testFile.Filename,
                Headers  = test.Headers.Select(x => new Models.HeaderItem {
                    Key = x.Key, Value = x.Value
                }).ToList(),
                CapturedVariables = test.CapturedVariables.Select(x => new CapturedVariableItem {
                    Name = x.Name, Regex = x.Regex, PostProcessorType = x.PostProcessorType
                }).ToList(),
                PostBody = test.PostBody,
                Method   = methodType,
                ExpectedHttpStatusCode = test.ExpectedHttpStatusCode,
                Description            = test.Description,
                Url        = test.Url,
                Assertions = test.Assertions.Select(x => new AssertionViewModel {
                    Value = x.Value, Description = x.Description, AssertionType = x.AssertionType, AssertionMethod = x.AssertionMethod
                }).ToList(),
                AvailableVariables          = BuildVariableViewModel(testFile),
                BeforeExecuteScriptFilename = test.ScriptSnippets.BeforeExecuteFilename,
                PageNumber           = pageNo,
                RequiredEnvironments = test.TestConditions.RequiredEnvironments,
                Environments         = _environmentsService.Get().OrderBy(x => x.Order).Select(x => x.Name).ToList()
            };

            PopulateScriptSnippets(model);

            return(model);
        }