Skip to content

Commit 8615375

Browse files
author
Jake Ginnivan
committed
Massive refactor around reporting...
1 parent 2ee3406 commit 8615375

File tree

37 files changed

+433
-247
lines changed

37 files changed

+433
-247
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Header
2-
------
1+
Passed: 'Header' for 'Fake data'
2+
--------------------------------
33

4-
Approved Exception
4+
With approved exceptions:
5+
Approved Exception

TestStack.ConventionTests.Tests/ConventionAssertionClassTests.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace TestStack.ConventionTests.Tests
22
{
3+
using System.Collections.Generic;
34
using ApprovalTests.Reporters;
45
using NUnit.Framework;
5-
using TestStack.ConventionTests.Internal;
66

77
[TestFixture]
88
[UseReporter(typeof(DiffReporter))] //NOTE: Can we take care of this in IsWithApprovedExceptions?
@@ -19,18 +19,26 @@ public void approval_mismatch()
1919
StringAssert.Contains("does not match approved file", ex.Message);
2020
}
2121

22-
public class FakeData : IConventionData
22+
public class FakeData : IConventionData, ICreateReportLineFor<string>
2323
{
24+
public string Description { get { return "Fake data"; } }
25+
2426
public void EnsureHasNonEmptySource()
2527
{
2628
}
29+
30+
public ConventionFailure CreateReportLine(string failingData)
31+
{
32+
return new ConventionFailure(failingData);
33+
}
2734
}
2835

29-
public class FailingConvention : IConvention<FakeData>
36+
public class FailingConvention : IConvention<FakeData, string>
3037
{
31-
public ConventionResult Execute(FakeData data)
38+
public string ConventionTitle { get { return "Header"; } }
39+
public IEnumerable<string> GetFailingData(FakeData data)
3240
{
33-
return ConventionResult.For("Header", new[] { "" }, (s, builder) => builder.AppendLine("Different"));
41+
return new[] {"Different"};
3442
}
3543
}
3644
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Some invalid assembly references found in TestStack.ConventionTests.Tests
2-
-------------------------------------------------------------------------
1+
Failed: 'Project must not reference dlls from bin or obj directories' for 'TestStack.ConventionTests.Tests'
2+
-----------------------------------------------------------------------------------------------------------
33

4-
bin\Debug\ApprovalTests.dll
4+
bin\Debug\ApprovalTests.dll
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Some invalid assembly references found in TestStack.ConventionTests.Tests
2-
-------------------------------------------------------------------------
1+
Passed: 'Project must not reference dlls from bin or obj directories' for 'TestStack.ConventionTests.Tests'
2+
-----------------------------------------------------------------------------------------------------------
33

4-
bin\Debug\ApprovalTests.dll
4+
With approved exceptions:
5+
bin\Debug\ApprovalTests.dll

TestStack.ConventionTests.Tests/ProjectBasedConventions.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ public void scripts_not_embedded_resources()
5757
.Returns(XDocument.Parse(Resources.ProjectFileWithInvalidSqlScriptFile));
5858

5959
var projectLocator = Substitute.For<IProjectLocator>();
60-
var project = new ProjectFiles(typeof (ProjectBasedConventions).Assembly, projectProvider, projectLocator)
61-
{
62-
Items = i => i.FilePath.EndsWith(".sql")
63-
};
64-
var ex = Assert.Throws<ConventionFailedException>(() => Convention.Is(new FilesAreEmbeddedResources(), project));
60+
var project = new ProjectFiles(typeof (ProjectBasedConventions).Assembly, projectProvider, projectLocator);
61+
var ex = Assert.Throws<ConventionFailedException>(() => Convention.Is(new FilesAreEmbeddedResources(".sql"), project));
6562

6663
Approvals.Verify(ex.Message);
6764
}
@@ -70,15 +67,12 @@ public void scripts_not_embedded_resources()
7067
public void scripts_not_embedded_resources_with_approved_exceptions()
7168
{
7269
var projectLocator = Substitute.For<IProjectLocator>();
73-
var project = new ProjectFiles(typeof(ProjectBasedConventions).Assembly, projectProvider, projectLocator)
74-
{
75-
Items = i => i.FilePath.EndsWith(".sql")
76-
};
70+
var project = new ProjectFiles(typeof (ProjectBasedConventions).Assembly, projectProvider, projectLocator);
7771
projectProvider
7872
.LoadProjectDocument(Arg.Any<string>())
7973
.Returns(XDocument.Parse(Resources.ProjectFileWithInvalidSqlScriptFile));
8074

81-
Convention.IsWithApprovedExeptions(new FilesAreEmbeddedResources(), project);
75+
Convention.IsWithApprovedExeptions(new FilesAreEmbeddedResources(".sql"), project);
8276
}
8377
}
8478
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The following files which should be embedded resources:
2-
-------------------------------------------------------
1+
Failed: '.sql Files must be embedded resources' for 'TestStack.ConventionTests.Tests'
2+
-------------------------------------------------------------------------------------
33

4-
Scripts\Script2.sql
4+
Scripts\Script2.sql
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
The following files which should be embedded resources:
2-
-------------------------------------------------------
1+
Passed: '.sql Files must be embedded resources' for 'TestStack.ConventionTests.Tests'
2+
-------------------------------------------------------------------------------------
33

4-
Scripts\Script2.sql
4+
With approved exceptions:
5+
Scripts\Script2.sql
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
The following types do not have default constructor
2-
---------------------------------------------------
1+
Failed: 'Types must have a default constructor' for 'nHibernate Entitites'
2+
--------------------------------------------------------------------------
33

44
TestAssembly.ClassWithNoDefaultCtor
5-
TestAssembly.ClassWithPrivateDefaultCtor
5+
TestAssembly.ClassWithPrivateDefaultCtor
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
The following types do not have default constructor
2-
---------------------------------------------------
1+
Passed: 'Types must have a default constructor' for 'nHibernate Entitites'
2+
--------------------------------------------------------------------------
33

4+
With approved exceptions:
45
TestAssembly.ClassWithNoDefaultCtor
5-
TestAssembly.ClassWithPrivateDefaultCtor
6+
TestAssembly.ClassWithPrivateDefaultCtor
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The following methods are not virtual.
2-
--------------------------------------
1+
Failed: 'Methods must be virtual' for 'nHibernate Entitites'
2+
------------------------------------------------------------
33

4-
TestAssembly.SampleDomainClass.TestNonVirtual
4+
TestAssembly.SampleDomainClass.TestNonVirtual

0 commit comments

Comments
 (0)