Exemplo n.º 1
0
        public async Task <IActionResult> AnalyzeTest(AnalyzeTestViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                var testInfos = await _runsProvider.GetAllTestsInfo();

                var test = await _runsProvider.GetTest(model.TestId);

                var viewTest = new ViewTest(test, testInfos);
                model.Test = viewTest;
                model.Run  = test.Run;
                var user = await _usersProvider.GetUser(User.GetUserId());

                var analyzeResolution = (AnalysisResolution)model.SelectedResolutionId;
                if (!model.SelectedStepId.HasValue)
                {
                    throw new Exception("Step was not specified");
                }
                await _runsProvider.SetAnalysisState(model.SelectedStepId.Value, analyzeResolution, model.IsExistingIssue,
                                                     model.ExistingIssueId, model.Title, model.Message, model.SelectedSuiteId, user);

                return(RedirectToAction("AnalyzeTest", "ResultsExplorer", new { @id = model.TestId }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                return(View(model));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CompareEnvironments(int id)
        {
            var folder = await _foldersProvider.GetActiveFolder();

            if (User.Identity.IsAuthenticated)
            {
                var user = await _usersProvider.GetUser(User.GetUserId());

                folder = user.SelectedFolder;
            }
            var runs = await _runsProvider.GetTestsForComparison(id, folder);

            var testInfo = await _runsProvider.GetAllTestsInfo();

            var model = new List <ViewTest>();

            foreach (var item in runs)
            {
                var info = testInfo.FirstOrDefault(p => p.TestName == item?.Name + ".py");
                if (info == null)
                {
                    continue;
                }
                var newTest = new ViewTest(item)
                {
                    SuitName = info.SuiteName,
                    Author   = info.AuthorLogin
                };
                model.Add(newTest);
            }
            return(View(model));
        }
        public List <ViewTest> GetAllTests()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM ViewTests ORDER BY TestName ASC";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();

            SqlDataReader   reader = command.ExecuteReader();
            List <ViewTest> tests  = new List <ViewTest>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    ViewTest test = new ViewTest();
                    test.TestName     = reader["TestName"].ToString();
                    test.TestFee      = Convert.ToDecimal(reader["TestFee"].ToString());
                    test.TestTypeName = reader["TestTypeName"].ToString();

                    tests.Add(test);
                }
                reader.Close();
            }
            connection.Close();
            return(tests);
        }
        public ViewTestButtonViewModel(ViewTest model)
        {
            // Setup initial conditions.
            this.model = model;
            Click = new DelegateCommand<Button>(button => OnClick());
            ParametersViewModel = new ViewTestParametersViewModel(model);

            // Wire up events.
            modelObserver = new PropertyObserver<ViewTest>(model)
                .RegisterHandler(m => m.ExecuteCount, m => OnPropertyChanged<T>(o => o.ExecuteCount));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> AnalyzeTest(long id)
        {
            var user = await _usersProvider.GetUser(User.GetUserId());

            var testInfos = await _runsProvider.GetAllTestsInfo();

            var model = new AnalyzeTestViewModel();
            var test  = await _runsProvider.GetTest(id);

            var viewTest = new ViewTest(test, testInfos);

            model.TestId      = id;
            model.CurrentUser = user;
            model.Test        = viewTest;
            model.Run         = test.Run;
            var failedStep = test.Steps.FirstOrDefault(p => !p.IsPassed);

            model.SelectedStepId = failedStep?.Id;
            model.Title          = $@"Fix {viewTest.Name} test";
            model.Message        =
                $@"Can not reproduce failure described at step: ""{failedStep?.Message.Trim()}"" for {test.Run.Environment.ConvertEnvironment()}";
            if (failedStep?.Stacktrace != null)
            {
                model.Message +=
                    $@" with the following stacktrace:{Environment.NewLine + failedStep?.Stacktrace.Replace("<<", "")}";
            }

            model.NewIssueMessage = $@"The test fails at step: ""{failedStep?.Message.Trim()}"" for {test.Run.Environment.ConvertEnvironment()}";
            if (failedStep?.Stacktrace != null)
            {
                model.NewIssueMessage +=
                    $@" with the following stacktrace:{Environment.NewLine + failedStep?.Stacktrace.Replace("<<", "")}";
            }

            model.KnownIssueMessage =
                $@"The failure is still reproducible for {test.Run.Environment.ConvertEnvironment()}";

            var testSuits = await _testLabProvider.GetAllTestSuits();

            model.TestSuitsModel = testSuits.OrderByDescending(p => p.Id).Select(p => new SelectListItem
            {
                Text  = p.Name,
                Value = p.Id.ToString()
            });
            model.Resolutions = ((AnalysisResolution[])Enum.GetValues(typeof(AnalysisResolution))).Select(p =>
                                                                                                          new SelectListItem
            {
                Text  = p.GetDescription(),
                Value = ((int)p).ToString()
            });
            model.TestSuitsModel = model.TestSuitsModel.OrderByDescending(p => int.Parse(p.Value));
            return(View(model));
        }
Exemplo n.º 6
0
        public async Task Create(ViewTest vm)
        {
            foreach (Question question in vm.Questions)
            {
                await _repoQ.CreateQuestion(question);
            }
            var current = new Test();
            var result  = vm.DiffUpdateProperties(current);
            await _repo.CreateTest(result);

            await _repo.SaveChangesAsync();
        }
        public void TestInitialize()
        {
            TestHarnessModel.ResetSingleton();
            var testHarness = TestHarnessModel.Instance;
            testHarness.Modules.RemoveAll();

            classModel = new ViewTestClass(typeof(SampleViewTestClass1), "File.xap");

            moduleModel = new ViewTestClassesAssemblyModule(new ModuleSetting(GetType().Assembly.FullName, "File.xap"));
            moduleModel.Classes.Add(classModel);
            testHarness.Modules.Add(moduleModel);

            classModel.IsCurrent = true;
            testModel = classModel.ViewTests[0];
        }
        public ViewTestParametersViewModel(ViewTest model)
        {
            // Setup initial conditions.
            if (model == null) throw new ArgumentNullException("model");
            EnumDropDowns = new ObservableCollection<ComboBoxViewModel>();

            // Populate with enum combo-boxes.
            var enumParams = from p in model.Parameters.Items
                             where p.Type.IsEnum || p.Type.IsA(typeof(bool))
                             select p;
            foreach (var parameter in enumParams)
            {
                EnumDropDowns.Add(CreateComboBox(parameter));
            }
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Edit(string id, ViewTest vm)
        {
            var test = _repo.GetTest(id);

            if (test == null)
            {
                var error = new { StatusText = "There is no item with this id" };
                return(BadRequest(error));
            }
            var result = vm.DiffUpdateProperties(test);

            _repo.UpdateTest(result);
            await _repo.SaveChangesAsync();

            return(Ok());
        }
        public IEnumerable <ViewTest> GetAll()
        {
            var result = from t in context.Tests
                         join e in context.Exams on t.ExamId equals e.Id
                         join s in context.SemesterExams on t.SemasterExamId equals s.ID
                         // where t.Status != 0
                         select new

            {
                t.Id,
                t.TestName,
                t.CreateBy,
                t.PassScore,
                e.NameExam,
                s.SemesterName,
                t.Status
            };
            List <ViewTest> list = new List <ViewTest>();

            foreach (var item in result)
            {
                ViewTest viewTest = new ViewTest();
                viewTest.Id           = item.Id;
                viewTest.TestName     = item.TestName;
                viewTest.CreateBy     = item.CreateBy;
                viewTest.PassScore    = item.PassScore;
                viewTest.NameExam     = item.NameExam;
                viewTest.SemesterName = item.SemesterName;
                viewTest.Status       = item.Status;
                list.Add(viewTest);
            }
            return(list);
            //var ques = context.Database.SqlQuery<ViewTest>
            //    ("select t.Id,t.TestName,t.CreateBy,PassScore, e.NameExam,s.SemesterName,t.Status from Tests t join Exams e on t.ExamId = e.Id join SemesterExam s on t.SemasterExamId = s.ID").ToList();
            //return ques.ToList();
        }
Exemplo n.º 11
0
        // GET
        public async Task <IActionResult> Index(int id, string suit, int filterOption, string query, string userFilter, int page = 1)
        {
            var filter = (TestExplorerFilter)filterOption;

            if (string.IsNullOrEmpty(suit))
            {
                suit = "ALL";
            }
            var run = await _runsProvider.GetRun(id);

            var testsInfo = await _runsProvider.GetAllTestsInfo();

            var testInfos     = testsInfo as TestInfo[] ?? testsInfo.ToArray();
            var testInfoTests = testInfos.Select(p => p.TestName).ToList();

            testsInfo = testInfos.ToList();

            var model = new TestsExplorerViewModel
            {
                Environment = run.Environment,
                ReportTime  = run.ReportTime,
                RunId       = run.Id
            };

            foreach (var test in run.Tests)
            {
                var testSuite = testsInfo.FirstOrDefault(p => p.TestName == test.Name + ".py");
                if (testSuite == null)
                {
                    continue;
                }
                {
                    var exists = model.TestSets.FirstOrDefault(p => p.Name == testSuite.SuiteName);
                    if (exists != null)
                    {
                        //add new tests to existing suite
                        var newTest = new ViewTest(test, testInfos);
                        exists.Tests.Add(newTest);
                    }
                    else
                    {
                        var newTestSuite = new TestSet
                        {
                            Name = testSuite.SuiteName,
                            Id   = testSuite.Id
                        };
                        var newTest = new ViewTest(test, testInfos);
                        newTestSuite.Tests.Add(newTest);
                        model.TestSets.Add(newTestSuite);
                    }
                }
            }

            foreach (var testSet in model.TestSets)
            {
                testSet.FailedTests = testSet.Tests.Count(p => p.Failed);
            }

            //display all tests
            var allTestSet = new TestSet
            {
                Name        = "ALL",
                FailedTests = run.Tests.Count(p => p.Steps.ToList().Exists(z => !z.IsPassed)),
                Id          = -1,
            };

            allTestSet.Tests = new List <ViewTest>();
            run.Tests.ToList().ForEach(p => allTestSet.Tests.Add(new ViewTest(p, testInfos)
                                                                 ));
            model.TestSets.Add(allTestSet);

            var notAssignedTests = run.Tests.Where(p => !testInfoTests.Contains(p.Name + ".py")).ToList();
            //Display not assigned
            var notAssignedTestSet = new TestSet
            {
                Name        = "NOT ASSIGNED",
                FailedTests = 0,
                Id          = 0,
                Tests       = new List <ViewTest>()
            };

            notAssignedTests.ToList().ForEach(p => allTestSet.Tests.Add(new ViewTest(p, testInfos)
                                                                        ));
            model.TestSets.Add(notAssignedTestSet);



            model.FilteredTestSets = model.TestSets.Clone();


            if (!string.IsNullOrEmpty(suit))
            {
                model.SelectedSuite    = suit;
                model.FilteredTestSets = model.FilteredTestSets.Where(p => p.Name == suit).ToList();
            }

            switch (filter)
            {
            case TestExplorerFilter.Total:
                break;

            case TestExplorerFilter.Passed:
                foreach (var testSets in model.FilteredTestSets)
                {
                    testSets.Tests = testSets.Tests.Where(p => p.Status == TestStatus.Passed).ToList();
                }

                break;

            case TestExplorerFilter.Failed:
                foreach (var testSets in model.FilteredTestSets)
                {
                    testSets.Tests = testSets.Tests.Where(p => p.Status == TestStatus.Failed).ToList();
                }
                break;

            case TestExplorerFilter.Errors:
                foreach (var testSets in model.FilteredTestSets)
                {
                    testSets.Tests = testSets.Tests.Where(p => p.Status == TestStatus.Error).ToList();
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }


            model.TestExplorerFilter = filter;
            model.Query = query;

            if (!string.IsNullOrEmpty(query))
            {
                foreach (var testSet in model.FilteredTestSets)
                {
                    if (query.Contains("!"))
                    {
                        testSet.Tests = testSet.Tests.Where(p => p.Name.Equals(query.Replace("!", ""))).ToList();
                    }
                    else
                    {
                        testSet.Tests = testSet.Tests.Where(p => p.Name.Contains(query)).ToList();
                    }
                }
            }

            model.Users = testInfos.Select(p => p.AuthorLogin).Distinct();
            if (userFilter != null)
            {
                model.UserFilter = userFilter;
                foreach (var testSet in model.FilteredTestSets)
                {
                    testSet.Tests = testSet.Tests.Where(p => p.Author == userFilter).ToList();
                }
            }

            model.Pager = new Pager(model.FilteredTestSets.SelectMany(p => p.Tests).Count(), page);


            return(View(model));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> TestsExplorer(int id, string suit, bool failedOnly)
        {
            var run = await _runsProvider.GetRun(id);

            var testsInfo = await _runsProvider.GetAllTestsInfo();

            testsInfo = testsInfo.ToList();

            var model = new TestsExplorerViewModel
            {
                Environment = run.Environment,
                ReportTime  = run.ReportTime,
                RunId       = run.Id
            };

            foreach (var test in run.Tests)
            {
                var testSuite = testsInfo.FirstOrDefault(p => p.TestName == test.Name + ".py");
                if (testSuite == null)
                {
                    continue;
                }
                {
                    var exists = model.TestSets.FirstOrDefault(p => p.Name == testSuite.SuiteName);
                    if (exists != null)
                    {
                        //add new tests to existing suite
                        var newTest = new ViewTest
                        {
                            Name        = test.Name,
                            Description = test.Description,
                            Author      = testSuite.AuthorLogin,
                            Failed      = test.Steps.Count(p => !p.IsPassed) != 0
                        };
                        foreach (var testStep in test.Steps)
                        {
                            newTest.Steps.Add(new ViewStep
                            {
                                DateTime   = testStep.Issued,
                                Message    = testStep.Message,
                                StackTrace = testStep.Stacktrace,
                                IsPassed   = testStep.IsPassed
                            });
                        }
                        exists.Tests.Add(newTest);
                    }
                    else
                    {
                        var newTestSuite = new TestSet
                        {
                            Name = testSuite.SuiteName,
                            Id   = testSuite.Id
                        };
                        var newTest = new ViewTest
                        {
                            Name        = test.Name,
                            Description = test.Description,
                            Author      = testSuite.AuthorLogin,
                            Failed      = test.Steps.Count(p => !p.IsPassed) != 0
                        };
                        foreach (var testStep in test.Steps)
                        {
                            newTest.Steps.Add(new ViewStep
                            {
                                DateTime   = testStep.Issued,
                                Message    = testStep.Message,
                                StackTrace = testStep.Stacktrace,
                                IsPassed   = testStep.IsPassed
                            });
                        }
                        newTestSuite.Tests.Add(newTest);
                        model.TestSets.Add(newTestSuite);
                    }
                }
            }

            foreach (var testSet in model.TestSets)
            {
                testSet.FailedTests = testSet.Tests.Count(p => p.Failed);
            }

            //display all tests
            var allTestSet = new TestSet
            {
                Name        = "All",
                FailedTests = run.Tests.Count(p => p.Steps.ToList().Exists(z => !z.IsPassed)),
                Id          = 0
            };

            allTestSet.Tests = new List <ViewTest>();
            run.Tests.ToList().ForEach(p => allTestSet.Tests.Add(new ViewTest
            {
                Name        = p.Name,
                Description = p.Description,
                Failed      = p.Steps.ToList().Exists(z => !z.IsPassed),
                Steps       = p.Steps.Select(q => new ViewStep(q)).ToList(),
                Author      = testsInfo.FirstOrDefault(z => z.TestName == (p.Name + ".py"))?.AuthorLogin
            }));
            model.TestSets.Add(allTestSet);


            model.FilteredTestSets = model.TestSets.Clone();

            if (!string.IsNullOrEmpty(suit))
            {
                model.SelectedSuite    = suit;
                model.FilteredTestSets = model.FilteredTestSets.Where(p => p.Name == suit).ToList();
            }

            if (!failedOnly)
            {
                return(View(model));
            }
            {
                foreach (var testSets in model.FilteredTestSets)
                {
                    testSets.Tests = testSets.Tests.Where(p => p.Failed).ToList();
                }
            }

            return(View(model));
        }
        //IEnumerable<ViewTest> ITestRepository<Test>.Search(string searchString)
        //{
        //    throw new NotImplementedException();
        //}
        public IEnumerable <ViewTest> Search(string searchString)
        {
            if (searchString != null && searchString != "undefined")
            {
                //var ques = context.Database.SqlQuery<ViewTest>
                //("  select t.Id,t.TestName,t.CreateBy,PassScore, e.NameExam,s.SemesterName,t.Status from Tests t join Exams e on t.ExamId = e.Id join SemesterExam s on t.SemasterExamId = s.ID where t.TestName like '%"+searchString+"%'").ToList();
                var result = from t in context.Tests
                             join e in context.Exams on t.ExamId equals e.Id
                             join s in context.SemesterExams on t.SemasterExamId equals s.ID
                             where t.TestName.Contains(searchString)
                             select new
                {
                    t.Id,
                    t.TestName,
                    t.CreateBy,
                    t.PassScore,
                    e.NameExam,
                    s.SemesterName
                };
                List <ViewTest> list = new List <ViewTest>();
                foreach (var item in result)
                {
                    ViewTest viewTest = new ViewTest();
                    viewTest.Id           = item.Id;
                    viewTest.TestName     = item.TestName;
                    viewTest.CreateBy     = item.CreateBy;
                    viewTest.PassScore    = item.PassScore;
                    viewTest.NameExam     = item.NameExam;
                    viewTest.SemesterName = item.SemesterName;
                    list.Add(viewTest);
                }
                return(list);
            }

            var resultt = from t in context.Tests
                          join e in context.Exams on t.ExamId equals e.Id
                          join s in context.SemesterExams on t.SemasterExamId equals s.ID

                          select new
            {
                t.Id,
                t.TestName,
                t.CreateBy,
                t.PassScore,
                e.NameExam,
                s.SemesterName
            };
            List <ViewTest> listt = new List <ViewTest>();

            foreach (var item in resultt)
            {
                ViewTest viewTest = new ViewTest();
                viewTest.Id           = item.Id;
                viewTest.TestName     = item.TestName;
                viewTest.CreateBy     = item.CreateBy;
                viewTest.PassScore    = item.PassScore;
                viewTest.NameExam     = item.NameExam;
                viewTest.SemesterName = item.SemesterName;
                listt.Add(viewTest);
            }


            return(listt);
        }
        private void OnTestExecuteRequest(object sender, EventArgs e)
        {
            // Store property state.
            currentViewTest = sender as ViewTest;

            // Update the set of controls instances.
            currentControls.Populate(currentViewTest.Parameters);

            // Alert listeners.
            FireExecuteRequest(currentViewTest);
            OnPropertyChanged<T>(m => m.CurrentViewTest, m => m.CurrentControls);

            // Pass execution back to the ViewTest with the set of controls.
            CurrentViewTest.Execute(Instance, currentViewTest.Parameters.ToArray());
        }
 private void FireExecuteRequest(ViewTest test) { if (ExecuteRequest != null) ExecuteRequest(this, new TestExecuteEventArgs{ViewTest = test}); }