コード例 #1
0
        public Case Build(TestCaseViewModel testCase)
        {
            if (testCase == null)
            {
                throw new ArgumentNullException("testCase");
            }

            return new Case
            {
                Id = testCase.Id,
                ErrorMessage = testCase.ErrorMessage,
                Headers = testCase.Headers.Select(x => new HeaderItem(x.Key, x.Value)).ToList(),
                LogRequest = testCase.LogRequest,
                LogResponse = testCase.LogResponse,
                LongDescription = testCase.LongDescription,
                Method = testCase.Method,
                ParentFilename = testCase.ParentFilename,
                ParseResponses = testCase.ParseResponses.Select(x => new ParseResponseItem(x.Description, x.Regex)).ToList(),
                PostBody = testCase.PostBody,
                VerifyPositives = testCase.Verifications.Where(x => x.VerifyType == VerifyType.Positive).Select(x => new VerificationItem(x.Description, x.Regex, x.VerifyType)).ToList(),
                VerifyNegatives = testCase.Verifications.Where(x => x.VerifyType == VerifyType.Negative).Select(x => new VerificationItem(x.Description, x.Regex, x.VerifyType)).ToList(),
                ShortDescription = testCase.ShortDescription,
                Url = testCase.Url,
                Sleep = testCase.Sleep,
                PostType = testCase.PostType.ToString(),
                VerifyResponseCode = testCase.VerifyResponseCode,
            };
        }
コード例 #2
0
        public ActionResult Edit(TestCaseViewModel model)
        {
            if (ModelState.IsValid)
            {
                var testCase = _testCaseCoreModelBuilder.Build(model);
                _casesClient.AddTestCase(testCase, _userContext.TeamName);
                return RedirectToAction("View", new { filename = model.ParentFilename });
            }

            return View("Edit", model);
        }
コード例 #3
0
        public TestCaseViewModel BuildTestCase(Case testCase)
        {
            if (testCase == null)
            {
                throw new ArgumentNullException("testCase");
            }

            var verifications = new List<Models.VerificationItem>();
            IEnumerable<Models.VerificationItem> verifyPositives = GetVerificationItems(testCase.VerifyPositives);
            IEnumerable<Models.VerificationItem> verifyNegatives = GetVerificationItems(testCase.VerifyNegatives);

            verifications.AddRange(verifyPositives);
            verifications.AddRange(verifyNegatives);

            var headerList = new List<Models.HeaderItem>(testCase.Headers.Select(x => new Models.HeaderItem { Key = x.Key, Value = x.Value }));
            var parsedResponses = new List<Models.ParseResponseItem>(testCase.ParseResponses.Select(x => new Models.ParseResponseItem { Description = x.Description, Regex = x.Regex }));

            var model = new TestCaseViewModel
            {
                Id = testCase.Id,
                ErrorMessage = testCase.ErrorMessage,
                Headers = headerList,
                LogRequest = testCase.LogRequest,
                LogResponse = testCase.LogResponse,
                LongDescription = testCase.LongDescription,
                Method = testCase.Method,
                ParseResponses = parsedResponses,
                PostBody = testCase.PostBody,
                PostType = testCase.PostType == PostType.GET.ToString() ? PostType.GET : PostType.POST,
                VerifyResponseCode = testCase.VerifyResponseCode,
                ShortDescription = testCase.ShortDescription,
                Sleep = testCase.Sleep,
                Url = testCase.Url,
                Verifications = verifications,
                ParentFilename = testCase.ParentFilename
            };

            return model;
        }