Esempio n. 1
0
        public static List <TestSummary> GetFailedTestResults(int[] TestRunIDs, DateTime?toDate, DateTime?fromDate, int outcome, bool isAdmin)
        {
            List <TestSummary> testResults = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                {
                    configset.Id,
                    configset.AnonymousAccess,
                    configset.Branch,
                    configset.Name
                };

                if (!isAdmin)
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                var filteredTestRunSets = dc.TestRunSets.Where(c => TestRunIDs.Contains(c.Id));
                var data = (from testrunset in filteredTestRunSets
                            join testresultset in dc.TestResultSets on testrunset.Id equals testresultset.TestRunId
                            join configset in configDetails on testrunset.TestConfigurationId equals configset.Id
                            where testresultset.Outcome == outcome
                            select new
                {
                    Outcome = testresultset.Outcome,
                    Error = testresultset.ErrorMessage,
                    StackTrace = testresultset.ErrorStackTrace,
                    TestDuration = testresultset.Duration,
                    TestCasename = testresultset.TestCaseName,
                    Id = testresultset.Id,
                    Branch = configset.Branch,
                    Configuration = configset.Name,
                    Testdate = testrunset.TestDate,
                    TestRunId = testrunset.Id
                }).ToList();

                if (data != null && data.Any())
                {
                    testResults = (from testresult in data
                                   select new TestSummary
                    {
                        Outcome = testresult.Outcome,
                        Error = testresult.Error,
                        StackTrace = testresult.StackTrace,
                        TestDuration = Convert.ToString(testresult.TestDuration),
                        TestCasename = testresult.TestCasename,
                        Id = testresult.Id,
                        Branch = testresult.Branch,
                        Configuration = testresult.Configuration,
                        Testdate = testresult.Testdate,
                        TestRunId = testresult.TestRunId
                    }).OrderByDescending(t => t.Id).ToList();
                }
            }

            return(testResults);
        }
Esempio n. 2
0
        public static List<EmailVerifiedUsers> GetAllEmailVerifiedUsers()
        {
            List<EmailVerifiedUsers> users = null;
            using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
            {
                users = (from userset in dbContext.UsersSets
                         where userset.IsEmailVerified == true && userset.SendTestResults == true
                         select new EmailVerifiedUsers
                         {
                             Email = userset.Email,
                             UPN = userset.UPN,
                             isAdmin = userset.IsAdmin,
                             isCoreMember = userset.IsCoreMember
                         }).ToList();

            }

            return users;
        }
Esempio n. 3
0
        public static List <EmailVerifiedUsers> GetAllEmailVerifiedUsers()
        {
            List <EmailVerifiedUsers> users = null;

            using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
            {
                users = (from userset in dbContext.UsersSets
                         where userset.IsEmailVerified == true && userset.SendTestResults == true
                         select new EmailVerifiedUsers
                {
                    Email = userset.Email,
                    UPN = userset.UPN,
                    isAdmin = userset.IsAdmin,
                    isCoreMember = userset.IsCoreMember
                }).ToList();
            }

            return(users);
        }
Esempio n. 4
0
        public static List<TestSummary> GetFailedTestResults(int[] TestRunIDs, DateTime? toDate, DateTime? fromDate, int outcome, bool isAdmin)
        {
            List<TestSummary> testResults = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                                    {
                                        configset.Id,
                                        configset.AnonymousAccess,
                                        configset.Branch,
                                        configset.Name,
                                        configset.TestCategory_Id

                                    };

                if (!isAdmin)
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                var filteredTestRunSets = dc.TestRunSets.Where(c => TestRunIDs.Contains(c.Id));
                var data = (from testrunset in filteredTestRunSets
                            join testresultset in dc.TestResultSets on testrunset.Id equals testresultset.TestRunId
                            join configset in configDetails on testrunset.TestConfigurationId equals configset.Id
                            join categorySet in dc.TestCategorySets on configset.TestCategory_Id equals categorySet.Id
                            where testresultset.Outcome == outcome
                            select new
                            {
                                Outcome = testresultset.Outcome,
                                Error = testresultset.ErrorMessage,
                                StackTrace = testresultset.ErrorStackTrace,
                                TestDuration = testresultset.Duration,
                                TestCasename = testresultset.TestCaseName,
                                Id = testresultset.Id,
                                Branch = configset.Branch,
                                Configuration = configset.Name,
                                CategoryName = categorySet.Name,
                                Testdate = testrunset.TestDate,
                                TestRunId = testrunset.Id
                            }).ToList();

                if (data != null && data.Any())
                {
                    testResults = (from testresult in data
                                   select new TestSummary
                                   {
                                       Outcome = testresult.Outcome,
                                       Error = testresult.Error,
                                       StackTrace = testresult.StackTrace,
                                       TestDuration = Convert.ToString(testresult.TestDuration),
                                       TestCasename = testresult.TestCasename,
                                       Id = testresult.Id,
                                       Branch = testresult.Branch,
                                       Configuration = testresult.Configuration,
                                       CategoryName = testresult.CategoryName,
                                       Testdate = testresult.Testdate,
                                       TestRunId = testresult.TestRunId
                                   }).OrderByDescending(t => t.Id).ToList();
                }

            }

            return testResults;
        }
Esempio n. 5
0
        public static List <AllRuns> GetCompletedTestRuns(DateTime?toDate, DateTime?fromDate, bool isAdmin)
        {
            List <AllRuns> configTestRuns = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                {
                    configset.Id,
                    configset.Name,
                    configset.Type,
                    configset.AnonymousAccess,
                    configset.TestCategory_Id,
                    configset.TestAuthentication_Id,
                    configset.Branch
                };

                if (!isAdmin)
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                var testResults = (from configset in configDetails
                                   join categorySet in dc.TestCategorySets on configset.TestCategory_Id equals categorySet.Id
                                   join authenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals authenticationset.Id
                                   join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                   //where testrunsets.TestDate >= fromDate && testrunsets.Status >= 2
                                   where DbFunctions.AddMilliseconds(testrunsets.TestDate, (DbFunctions.DiffMilliseconds(TimeSpan.Zero, testrunsets.TestTime) ?? 0)) >= fromDate &&
                                   DbFunctions.AddMilliseconds(testrunsets.TestDate, (DbFunctions.DiffMilliseconds(TimeSpan.Zero, testrunsets.TestTime) ?? 0)) < toDate &&
                                   testrunsets.Status >= 2
                                   select new
                {
                    Status = testrunsets.Status,
                    Testdate = testrunsets.TestDate,
                    TestDuration = testrunsets.TestTime,
                    Passed = testrunsets.TestsPassed,
                    Skipped = testrunsets.TestsSkipped,
                    Failed = testrunsets.TestsFailed,
                    Log = (testrunsets.MSBuildLog != null ? true : false),
                    TestRunSetId = testrunsets.Id,
                    CId = testrunsets.TestConfigurationId,
                    cName = configset.Name,
                    CategoryName = categorySet.Name,
                    appOnly = authenticationset.AppOnly,
                    cType = configset.Type,
                    GithubBranch = configset.Branch
                }).OrderByDescending(t => t.Testdate).ToList();

                configTestRuns = (from testrunsets in testResults
                                  select new AllRuns
                {
                    Status = testrunsets.Status,
                    ConfiguratioName = testrunsets.cName,
                    GithubBranch = testrunsets.GithubBranch,
                    CategoryName = testrunsets.CategoryName,
                    AppOnly = Enum.GetName(typeof(AppOnly), testrunsets.appOnly),
                    Environment = Enum.GetName(typeof(EnvironmentType), testrunsets.cType),
                    Testdate = testrunsets.Testdate,
                    TestDuration = Convert.ToString(testrunsets.TestDuration),
                    Passed = (testrunsets.Passed != null ? testrunsets.Passed : 0),
                    Skipped = (testrunsets.Skipped != null ? testrunsets.Skipped : 0),
                    Failed = (testrunsets.Failed != null ? testrunsets.Failed : 0),
                    Log = testrunsets.Log,
                    TestRunSetId = testrunsets.TestRunSetId,
                    Tests = ((testrunsets.Passed != null ? testrunsets.Passed : 0)
                             + (testrunsets.Skipped != null ? testrunsets.Skipped : 0)
                             + (testrunsets.Failed != null ? testrunsets.Failed : 0))
                }).OrderByDescending(d => d.Testdate.Date).ThenByDescending(t => t.Testdate.TimeOfDay).ToList();
            }

            return(configTestRuns);
        }
Esempio n. 6
0
        public static List<AllRuns> GetCompletedTestRuns(DateTime? toDate,DateTime? fromDate, bool isAdmin)
        {
            List<AllRuns> configTestRuns = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                                    {
                                        configset.Id,
                                        configset.Name,
                                        configset.Type,
                                        configset.AnonymousAccess,
                                        configset.TestCategory_Id,
                                        configset.TestAuthentication_Id,
                                        configset.Branch
                                    };

                if (!isAdmin)
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                var testResults = (from configset in configDetails
                                   join categorySet in dc.TestCategorySets on configset.TestCategory_Id equals categorySet.Id
                                   join authenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals authenticationset.Id
                                   join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                   //where testrunsets.TestDate >= fromDate && testrunsets.Status >= 2
                                   where DbFunctions.AddMilliseconds(testrunsets.TestDate, (DbFunctions.DiffMilliseconds(TimeSpan.Zero, testrunsets.TestTime) ?? 0)) >= fromDate
                                   && DbFunctions.AddMilliseconds(testrunsets.TestDate, (DbFunctions.DiffMilliseconds(TimeSpan.Zero, testrunsets.TestTime) ?? 0)) < toDate
                                    && testrunsets.Status >= 2
                                   select new
                                   {
                                       Status = testrunsets.Status,
                                       Testdate = testrunsets.TestDate,
                                       TestDuration = testrunsets.TestTime,
                                       Passed = testrunsets.TestsPassed,
                                       Skipped = testrunsets.TestsSkipped,
                                       Failed = testrunsets.TestsFailed,
                                       Log = (testrunsets.MSBuildLog != null ? true : false),
                                       TestRunSetId = testrunsets.Id,
                                       CId = testrunsets.TestConfigurationId,
                                       cName = configset.Name,
                                       CategoryName = categorySet.Name,
                                       appOnly = authenticationset.AppOnly,
                                       cType = configset.Type,
                                       GithubBranch = configset.Branch
                                   }).OrderByDescending(t => t.Testdate).ToList();

                configTestRuns = (from testrunsets in testResults
                                                select new AllRuns
                                                {
                                                    Status = testrunsets.Status,
                                                    ConfiguratioName = testrunsets.cName,
                                                    GithubBranch = testrunsets.GithubBranch,
                                                    CategoryName = testrunsets.CategoryName,
                                                    AppOnly = Enum.GetName(typeof(AppOnly), testrunsets.appOnly),
                                                    Environment = Enum.GetName(typeof(EnvironmentType), testrunsets.cType),
                                                    Testdate = testrunsets.Testdate,
                                                    TestDuration = Convert.ToString(testrunsets.TestDuration),
                                                    Passed = (testrunsets.Passed != null ? testrunsets.Passed : 0),
                                                    Skipped = (testrunsets.Skipped != null ? testrunsets.Skipped : 0),
                                                    Failed = (testrunsets.Failed != null ? testrunsets.Failed : 0),
                                                    Log = testrunsets.Log,
                                                    TestRunSetId = testrunsets.TestRunSetId,
                                                    Tests = ((testrunsets.Passed != null ? testrunsets.Passed : 0)
                                                      + (testrunsets.Skipped != null ? testrunsets.Skipped : 0)
                                                      + (testrunsets.Failed != null ? testrunsets.Failed : 0))
                                                }).OrderByDescending(d => d.Testdate.Date).ThenByDescending(t => t.Testdate.TimeOfDay).ToList();
            }

            return configTestRuns;
        }