Esempio n. 1
0
 private void SaveTestFailedDuration(DbTestFailureDuration testFailedDuration)
 {
     if (testFailedDuration.TestFailureDurationID == 0)
     {
         _db.TestFailureDurations.Add(testFailedDuration);
     }
     _db.SaveChanges();
 }
Esempio n. 2
0
 // todo: move to mapping class
 private TestFailureDurationDto Map(DbTestFailureDuration dbTestFailureDuration)
 {
     return(new TestFailureDurationDto
     {
         TestFailureDurationID = dbTestFailureDuration.TestFailureDurationID,
         TestResultId = dbTestFailureDuration.TestResultId,
         TestId = dbTestFailureDuration.TestId,
         SuiteId = dbTestFailureDuration.SuiteId,
         FailureEnd = dbTestFailureDuration.FailureEndDateTime,
         FailureStart = dbTestFailureDuration.FailureStartDateTime
     });
 }
Esempio n. 3
0
        public TestFailureDurationDto Save(TestFailureDurationDto testFailureDurationDto, TestResultType testResultType, DateTime utcNow)
        {
            var latestDbTestFailedDuration = _db.TestFailureDurations
                                             .OrderByDescending(f => f.FailureStartDateTime)
                                             .FirstOrDefault(f =>
                                                             f.SuiteId == testFailureDurationDto.SuiteId &&
                                                             f.TestId == testFailureDurationDto.TestId
                                                             );

            if (testResultType == TestResultType.Pass &&
                latestDbTestFailedDuration != null &&
                latestDbTestFailedDuration.FailureStartDateTime != null && latestDbTestFailedDuration.FailureEndDateTime == null)
            {
                latestDbTestFailedDuration.TestResultId       = testFailureDurationDto.TestResultId;
                latestDbTestFailedDuration.FailureEndDateTime = utcNow;
                SaveTestFailedDuration(latestDbTestFailedDuration);
                return(Map(latestDbTestFailedDuration));
            }
            else if (testResultType == TestResultType.Fail || testResultType == TestResultType.Inconclusive)
            {
                if (latestDbTestFailedDuration == null || latestDbTestFailedDuration.FailureEndDateTime != null)
                {
                    var newDbTestFailedDuration = new DbTestFailureDuration
                    {
                        SuiteId              = testFailureDurationDto.SuiteId,
                        TestId               = testFailureDurationDto.TestId,
                        TestResultId         = testFailureDurationDto.TestResultId,
                        FailureStartDateTime = utcNow
                    };
                    SaveTestFailedDuration(newDbTestFailedDuration);
                    return(Map(newDbTestFailedDuration));
                }
            }

            return(null);
        }