private TestStats GetStatistics(IEnumerable <XElement> elements) { TestStats stats = new TestStats(); foreach (XElement element in elements) { TestStats elementStats = GetStatistics(element); switch (elementStats.Outcome) { case StepStatusEnum.Done: stats.Done += elementStats.Done; break; case StepStatusEnum.Pass: stats.Pass += elementStats.Pass; break; case StepStatusEnum.Warning: stats.Warning += elementStats.Warning; break; case StepStatusEnum.Fail: stats.Fail += elementStats.Fail; break; case StepStatusEnum.Error: stats.Error += elementStats.Error; break; case StepStatusEnum.Fatal: stats.Fatal += elementStats.Fatal; break; } } stats.Calculate(); return(stats); }
private TestStats GetStatistics(XElement element) { TestStats stats = new TestStats(); try { stats.Done = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Done).ToLower()).Value); } catch { stats.Done = 0; } try { stats.Pass = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Pass).ToLower()).Value); } catch { stats.Pass = 0; } try { stats.Warning = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Warning).ToLower()).Value); } catch { stats.Warning = 0; } try { stats.Fail = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Fail).ToLower()).Value); } catch { stats.Fail = 0; } try { stats.Error = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Error).ToLower()).Value); } catch { stats.Error = 0; } try { stats.Fatal = Convert.ToInt32(element.Attribute(Enum.GetName(typeof(StepStatusEnum), StepStatusEnum.Fatal).ToLower()).Value); } catch { stats.Fatal = 0; } stats.Calculate(); return(stats); }