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); }
private void SaveTestDurations(GtaTestDurations durations, string durationsFile) { using (var fileStream = new StreamWriter(durationsFile)) { _serializer.Serialize(fileStream, durations); } }
private void SaveTestDurations(GtaTestDurations durations, string durationsFile) { TextWriter fileStream = new StreamWriter(durationsFile); Serializer.Serialize(fileStream, durations); fileStream.Close(); }
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); }
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); }
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); }