/
StubListener.cs
56 lines (45 loc) · 1.38 KB
/
StubListener.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Fixie.Tests
{
public class StubListener : Listener
{
readonly List<string> log = new List<string>();
public void AssemblyStarted(Assembly assembly)
{
}
public void CaseSkipped(Case @case)
{
log.Add(string.Format("{0} skipped.", @case.Name));
}
public void CasePassed(PassResult result)
{
var @case = result.Case;
log.Add(string.Format("{0} passed.", @case.Name));
}
public void CaseFailed(FailResult result)
{
var @case = result.Case;
var exceptions = result.Exceptions;
var entry = new StringBuilder();
var primary = exceptions.First();
entry.Append(string.Format("{0} failed: {1}", @case.Name, primary.Message));
foreach (var exception in exceptions.Skip(1))
{
entry.AppendLine();
entry.Append(string.Format(" Secondary Failure: {0}", exception.Message));
}
log.Add(entry.ToString());
}
public void AssemblyCompleted(Assembly assembly, AssemblyResult result)
{
}
public IEnumerable<string> Entries
{
get { return log; }
}
}
}