示例#1
0
        private IDictionary <TestCase, int> ReadTestDurations(string executable, List <TestCase> testcases)
        {
            var    durations     = new Dictionary <TestCase, int>();
            string durationsFile = GetDurationsFile(executable);

            if (!File.Exists(durationsFile))
            {
                return(durations);
            }

            GtaTestDurations container;

            lock (Lock)
            {
                container = LoadTestDurations(durationsFile);
            }

            foreach (TestCase testcase in testcases)
            {
                TestDuration pair = container.TestDurations.FirstOrDefault(p => p.Test == testcase.FullyQualifiedName);
                if (!pair.Equals(Default))
                {
                    durations.Add(testcase, pair.Duration);
                }
            }

            return(durations);
        }
示例#2
0
        private void UpdateTestDurations(string executable, List <TestResult> testresults)
        {
            string           durationsFile = GetDurationsFile(executable);
            GtaTestDurations container     = File.Exists(durationsFile) ? LoadTestDurations(durationsFile) : new GtaTestDurations();

            container.Executable = Path.GetFullPath(executable);

            foreach (TestResult testResult in testresults.Where(tr => tr.Outcome == TestOutcome.Passed || tr.Outcome == TestOutcome.Failed))
            {
                TestDuration pair = container.TestDurations.FirstOrDefault(p => p.Test == testResult.TestCase.FullyQualifiedName);
                if (!pair.Equals(Default))
                {
                    container.TestDurations.Remove(pair);
                }
                container.TestDurations.Add(new TestDuration(testResult.TestCase.FullyQualifiedName, GetDuration(testResult)));
            }

            SaveTestDurations(container, durationsFile);
        }