private static string BuildFullyQualifiedName(Models.TestCase testCase)
        {
            var filePath = !string.IsNullOrEmpty(testCase.PathFromTestSettingsDirectory) ? testCase.PathFromTestSettingsDirectory : testCase.InputTestFile;
            var parts    = new[] { filePath, testCase.ModuleName, testCase.TestName };

            return(String.Join("::", parts).ToLowerInvariant());
        }
Esempio n. 2
0
        public static TestResult ToVsTestResult(this Models.TestCase test)
        {
            var        testCase = test.ToVsTestCase();
            TestResult result;

            if (test.Passed)
            {
                result = new TestResult(testCase)
                {
                    Duration    = TimeSpan.FromMilliseconds(test.TimeTaken),
                    DisplayName = testCase.DisplayName,
                    Outcome     = ToVsTestOutcome(true)
                };
            }
            else
            {
                var failureResult = test.TestResults.FirstOrDefault(x => !x.Passed);
                result = new TestResult(testCase)
                {
                    Duration     = TimeSpan.FromMilliseconds(test.TimeTaken),
                    DisplayName  = testCase.DisplayName,
                    ErrorMessage = GetTestFailureMessage(failureResult),
                    Outcome      = ToVsTestOutcome(false)
                };
            }

            return(result);
        }
Esempio n. 3
0
        public JsonResult AddTestCases(Models.TestCase TestCase)
        {
            //question.Date = DateTime.Parse(DateTime.Now.ToShortTimeString());
            tbotEntities e = new tbotEntities();

            e.TestCases.Add(TestCase);

            //e.APIs.Add(apiInput);
            e.SaveChanges();
            return(Json(new { status = "Api Input added successfully" }));
        }
Esempio n. 4
0
        public static TestCase ToVsTestCase(this Models.TestCase test)
        {
            var normalizedPath = test.InputTestFile.ToLowerInvariant();
            var testCase       = new TestCase(BuildFullyQualifiedName(test), AdapterConstants.ExecutorUri, normalizedPath)
            {
                CodeFilePath = normalizedPath,
                DisplayName  = GetTestDisplayText(test),
                LineNumber   = test.Line,
            };


            testCase.Traits.Add("Module", test.ModuleName);
            return(testCase);
        }
Esempio n. 5
0
        public ActionResult GetTestCaseById(int id)
        {
            ValidationMapper <TestCase, Models.TestCase> mapperObj = new ValidationMapper <TestCase, Models.TestCase>();
            var dalObj   = new DALRepository();
            var tstCase  = dalObj.GetTestCasesById(id);
            var tstCasem = new Models.TestCase();

            if (tstCase != null)
            {
                tstCasem = mapperObj.Translate(tstCase);
                return(Json(tstCasem, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Esempio n. 6
0
        public JsonResult DeleteTestCase(Models.TestCase testCase)
        {
            int result = 0; bool status = false;

            try
            {
                var dalObj = new DALRepository();
                result = dalObj.DeleteTestcase(testCase.TestCaseId);
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 7
0
        public JsonResult UpdateTestCase(Models.TestCase testcase)
        {
            int result = 0; bool status = false;

            try
            {
                ValidationMapper <Models.TestCase, TestCase> mapperObj = new ValidationMapper <Models.TestCase, TestCase>();
                var dalObj = new DALRepository();
                result = dalObj.UpdatedTestcase(mapperObj.Translate(testcase));
                if (result == 1)
                {
                    status = true;
                }
                return(Json(new { success = status }));
            }
            catch
            {
                return(Json(new { success = status }));
            }
        }
Esempio n. 8
0
        private List <TestCaseExecution> GetTestCaseDataFromDTO(SingleDeviceTestSuiteRun testRun, NUnitReportSummary nUnitReportSummary)
        {
            var testcases      = new List <Models.TestCase>();
            var testExecutions = new List <Models.TestCaseExecution>();

            //TODO: implement attachments
            var attachments = new List <Models.TestCase_Attachment>();

            //Loop though NUnit TestCases and create TestPond Models of Test Case and Execution
            foreach (var tc in nUnitReportSummary.Testcases)
            {
                var testPondTestCase = new Models.TestCase()
                {
                    Id = tc.Fullname
                };

                Enum.TryParse(tc.Result, out TestResult result);

                var testPondTestCaseExec = new Models.TestCaseExecution()
                {
                    TestCaseId = testPondTestCase.Id,
                    ClassName  = tc.Classname,
                    TestCase   = testPondTestCase,
                    SingleDeviceTestSuiteRunId = testRun.Id,
                    SingleDeviceTestSuiteRun   = testRun,
                    Result            = result,
                    ConsoleOutput     = tc.Output,
                    FailureMessage    = tc.Failure?.Message,
                    FailureStackTrace = tc.Failure?.Stacktrace
                };

                testcases.Add(testPondTestCase);
                testExecutions.Add(testPondTestCaseExec);
            }

            return(testExecutions);
        }
Esempio n. 9
0
 private static string GetTestDisplayText(Models.TestCase testCase)
 {
     return(string.IsNullOrWhiteSpace(testCase.ModuleName) ? testCase.TestName : string.Format("{0} {1}", testCase.ModuleName, testCase.TestName));
 }
Esempio n. 10
0
        private static string BuildFullyQualifiedName(Models.TestCase testCase)
        {
            var parts = new[] { testCase.InputTestFile, testCase.ModuleName, testCase.TestName };

            return(String.Join("::", parts).ToLowerInvariant());
        }
Esempio n. 11
0
 /// <summary>
 /// Builds an artifical stack trace so that errors coming from test adapter contains a reference to the file and test name
 /// without needing to read the whole log
 /// </summary>
 private static string BuildVirtualStackTrace(Models.TestCase testCase)
 {
     return(string.Format("at {0} in {1}:line {2}{3}", GetTestDisplayText(testCase), testCase.InputTestFile, testCase.Line, Environment.NewLine));
 }
Esempio n. 12
0
        public JsonResult jqueryGettestcases(int Id, int?page, int?limit, string sortBy, string direction, Models.TestCase testcas)
        {
            ValidationMapper <TestCase, Models.TestCase> mapperObj = new ValidationMapper <TestCase, Models.TestCase>();
            var dalObj        = new DALRepository();
            var testSuiteList = dalObj.Gettestsuitechilds();
            var records       = new List <Models.TestCase>();
            var query         = testSuiteList.Select(p => new Models.TestCase
            {
                TestCaseId      = p.TestCaseId,
                TestCaseTypeId  = p.TestCaseTypeId,
                TestSuiteId     = p.TestSuiteId,
                TestCaseName    = p.TestCaseName,
                CreatedBy       = p.CreatedBy,
                CreatedDate     = p.CreatedDate,
                IsActive        = p.IsActive,
                PipelineStageId = p.PipelineStageId,
                Description     = p.Description,
                IsObsolete      = p.IsObsolete,
                ObsoleteReason  = p.ObsoleteReason
            });

            if (Id != 0)
            {
                query = query.Where(q => q.TestSuiteId == Id);
            }
            if (!string.IsNullOrWhiteSpace(testcas.TestCaseName))
            {
                query = query.Where(q => q.TestCaseName.Contains(testcas.TestCaseName));
            }

            if (testcas.IsActive)
            {
                query = query.Where(q => q.IsActive.Equals(testcas.IsActive));
            }
            if (testcas.IsObsolete)
            {
                query = query.Where(q => q.IsObsolete.Equals(testcas.IsObsolete));
            }
            if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction))
            {
                if (direction.Trim().ToLower() == "asc")
                {
                    switch (sortBy.Trim().ToLower())
                    {
                    case "testcasename":
                        query = query.OrderBy(q => q.TestCaseName);
                        break;

                    case "createddate":
                        query = query.OrderBy(q => q.CreatedDate);
                        break;

                    case "testsuiteid":
                        query = query.OrderBy(q => q.TestSuiteId);
                        break;

                    case "testcasetypeid":
                        query = query.OrderBy(q => q.TestCaseTypeId);
                        break;

                    case "pipelinestageid":
                        query = query.OrderBy(q => q.PipelineStageId);
                        break;

                    case "testcaseid":
                        query = query.OrderBy(q => q.TestCaseId);
                        break;
                    }
                }
                else
                {
                    switch (sortBy.Trim().ToLower())
                    {
                    case "testcasename":
                        query = query.OrderByDescending(q => q.TestCaseName);
                        break;

                    case "createddate":
                        query = query.OrderByDescending(q => q.CreatedDate);
                        break;

                    case "testsuiteid":
                        query = query.OrderByDescending(q => q.TestSuiteId);
                        break;

                    case "testcasetypeid":
                        query = query.OrderByDescending(q => q.TestCaseTypeId);
                        break;

                    case "pipelinestageid":
                        query = query.OrderByDescending(q => q.PipelineStageId);
                        break;

                    case "testcaseid":
                        query = query.OrderByDescending(q => q.TestCaseId);
                        break;
                    }
                }
            }
            else
            {
                query = query.OrderBy(q => q.TestCaseId);
            }
            var total = query.Count();

            if (page.HasValue && limit.HasValue)
            {
                int start = (page.Value - 1) * limit.Value;
                records = query.Skip(start).Take(limit.Value).ToList();
            }
            else
            {
                records = query.ToList();
            }
            return(this.Json(new { records, total }, JsonRequestBehavior.AllowGet));
        }