Skip to content

Commit 924c46e

Browse files
committed
Merge pull request #26 from JakeGinnivan/reportingAndFormatting
Reporting and formatting
2 parents 820ded8 + dd0667d commit 924c46e

34 files changed

+418
-180
lines changed

TestAssembly/Collections/Branch.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace TestAssembly.Collections
2+
{
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
public class Branch : IEnumerable<Leaf>
7+
{
8+
readonly List<Leaf> items = new List<Leaf>();
9+
10+
public IEnumerator<Leaf> GetEnumerator()
11+
{
12+
return items.GetEnumerator();
13+
}
14+
15+
IEnumerator IEnumerable.GetEnumerator()
16+
{
17+
return GetEnumerator();
18+
}
19+
}
20+
}

TestAssembly/Collections/Forest.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace TestAssembly.Collections
2+
{
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
public class Forest : ICanAdd<Tree>, ICanRemove<Tree>
7+
{
8+
readonly List<Tree> items = new List<Tree>();
9+
10+
public void Add(Tree item)
11+
{
12+
items.Add(item);
13+
}
14+
15+
IEnumerator IEnumerable.GetEnumerator()
16+
{
17+
return ((IEnumerable) items).GetEnumerator();
18+
}
19+
20+
public IEnumerator<Tree> GetEnumerator()
21+
{
22+
return items.GetEnumerator();
23+
}
24+
25+
public bool Remove(Tree item)
26+
{
27+
return items.Remove(item);
28+
}
29+
}
30+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace TestAssembly.Collections
2+
{
3+
using System.Collections.Generic;
4+
5+
public interface ICanAdd<T> : IEnumerable<T>
6+
{
7+
void Add(T item);
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace TestAssembly.Collections
2+
{
3+
using System.Collections.Generic;
4+
5+
public interface ICanRemove<T> : IEnumerable<T>
6+
{
7+
bool Remove(T item);
8+
}
9+
}

TestAssembly/Collections/Leaf.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace TestAssembly.Collections
2+
{
3+
public class Leaf
4+
{
5+
}
6+
}

TestAssembly/Collections/Tree.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace TestAssembly.Collections
2+
{
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
7+
public class Tree : ICanAdd<Branch>, IEnumerable<Leaf>
8+
{
9+
readonly List<Branch> items = new List<Branch>();
10+
11+
public void Add(Branch item)
12+
{
13+
items.Add(item);
14+
}
15+
16+
public IEnumerator<Branch> GetEnumerator()
17+
{
18+
return items.GetEnumerator();
19+
}
20+
21+
IEnumerator IEnumerable.GetEnumerator()
22+
{
23+
return GetEnumerator();
24+
}
25+
26+
IEnumerator<Leaf> IEnumerable<Leaf>.GetEnumerator()
27+
{
28+
return items.SelectMany(i => i).GetEnumerator();
29+
}
30+
}
31+
}

TestAssembly/TestAssembly.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@
4444
<Compile Include="ClassWithPrivateDefaultCtor.cs" />
4545
<Compile Include="ClassWithProtectedDefaultCtor.cs" />
4646
<Compile Include="ClassWithPublicDefaultCtor.cs" />
47+
<Compile Include="Collections\Branch.cs" />
48+
<Compile Include="Collections\Forest.cs" />
49+
<Compile Include="Collections\ICanAdd.cs" />
50+
<Compile Include="Collections\ICanRemove.cs" />
51+
<Compile Include="Collections\Leaf.cs" />
52+
<Compile Include="Collections\Tree.cs" />
4753
<Compile Include="Dtos\AnotherClass.cs" />
4854
<Compile Include="Dtos\BlahDto.cs" />
4955
<Compile Include="Properties\AssemblyInfo.cs" />

TestStack.ConventionTests.Tests/ConventionAssertionClassTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ConventionReportFailure Format(string failingData)
3333

3434
public class FailingConvention : IConvention<FakeData>
3535
{
36-
public void Execute(FakeData data, IConventionResult result)
36+
public void Execute(FakeData data, IConventionResultContext result)
3737
{
3838
result.Is("Header", new[] {"Different"});
3939
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
collection,item,can add,can remove
2+
TestAssembly.Collections.Branch,TestAssembly.Collections.Leaf,False,False
3+
TestAssembly.Collections.Forest,TestAssembly.Collections.Tree,True,True
4+
TestAssembly.Collections.Tree,TestAssembly.Collections.Branch,True,False
5+
TestAssembly.Collections.Tree,TestAssembly.Collections.Leaf,False,False
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace TestStack.ConventionTests.Tests
2+
{
3+
using System.Linq;
4+
using ApprovalTests.Reporters;
5+
using NUnit.Framework;
6+
using TestAssembly.Collections;
7+
using TestStack.ConventionTests.ConventionData;
8+
using TestStack.ConventionTests.Tests.TestConventions;
9+
10+
[UseReporter(typeof(DiffReporter))]
11+
public class CsvReportTests
12+
{
13+
[Test]
14+
public void Can_run_convention_with_simple_reporter()
15+
{
16+
Convention.IsWithApprovedExeptions(new CollectionsRelationsConvention(), new Types("Entities")
17+
{
18+
TypesToVerify =
19+
typeof (Leaf).Assembly.GetExportedTypes()
20+
.Where(t => t.Namespace == typeof (Leaf).Namespace).ToArray()
21+
});
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)