コード例 #1
0
        private void UpdateTestDurations(string executable, List <TestResult> testresults)
        {
            string           durationsFile = GetDurationsFile(executable);
            GtaTestDurations container     = null;

            if (File.Exists(durationsFile))
            {
                try
                {
                    container = LoadTestDurations(durationsFile);
                }
                catch
                { }
            }
            if (container == null)
            {
                container = new GtaTestDurations();
            }
            container.Executable = Path.GetFullPath(executable);

            IDictionary <string, TestDuration> durations = container.TestDurations.ToDictionary(x => x.Test, x => x);

            foreach (TestResult testResult in
                     testresults.Where(tr => tr.Outcome == TestOutcome.Passed || tr.Outcome == TestOutcome.Failed))
            {
                durations[testResult.TestCase.FullyQualifiedName] =
                    new TestDuration(testResult.TestCase.FullyQualifiedName, GetDuration(testResult));
            }

            container.TestDurations.Clear();
            container.TestDurations.AddRange(durations.Values);

            SaveTestDurations(container, durationsFile);
        }
コード例 #2
0
 private void SaveTestDurations(GtaTestDurations durations, string durationsFile)
 {
     using (var fileStream = new StreamWriter(durationsFile))
     {
         _serializer.Serialize(fileStream, durations);
     }
 }
コード例 #3
0
        private void SaveTestDurations(GtaTestDurations durations, string durationsFile)
        {
            TextWriter fileStream = new StreamWriter(durationsFile);

            Serializer.Serialize(fileStream, durations);
            fileStream.Close();
        }
コード例 #4
0
        private GtaTestDurations LoadTestDurations(string durationsFile)
        {
            FileStream       fileStream = new FileStream(durationsFile, FileMode.Open, FileAccess.Read, FileShare.Read);
            GtaTestDurations container  = Serializer.Deserialize(fileStream) as GtaTestDurations;

            fileStream.Close();
            return(container);
        }
コード例 #5
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);
        }
コード例 #6
0
        private IDictionary <TestCase, int> ReadTestDurations(string executable, List <TestCase> testcases)
        {
            IDictionary <TestCase, int> durations = new Dictionary <TestCase, int>();
            string durationsFile = GetDurationsFile(executable);

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

            GtaTestDurations 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);
        }
コード例 #7
0
 private void SaveTestDurations(GtaTestDurations durations, string durationsFile)
 {
     using (var fileStream = new StreamWriter(durationsFile))
     {
         _serializer.Serialize(fileStream, durations);
     }
 }