1
1
namespace TestStack . ConventionTests . Tests
2
2
{
3
3
using System . Xml . Linq ;
4
- using ApprovalTests ;
5
- using ApprovalTests . Reporters ;
6
4
using NSubstitute ;
7
5
using NUnit . Framework ;
6
+ using Shouldly ;
8
7
using TestStack . ConventionTests . ConventionData ;
9
8
using TestStack . ConventionTests . Conventions ;
10
9
using TestStack . ConventionTests . Internal ;
11
10
using TestStack . ConventionTests . Tests . Properties ;
12
11
13
12
[ TestFixture ]
14
- [ UseReporter ( typeof ( DiffReporter ) ) ]
15
13
public class ProjectBasedConventions
16
14
{
17
15
IProjectProvider projectProvider ;
@@ -31,9 +29,9 @@ public void assemblies_referencing_bin_obj()
31
29
32
30
var projectLocator = Substitute . For < IProjectLocator > ( ) ;
33
31
var project = new ProjectReferences ( typeof ( ProjectBasedConventions ) . Assembly , projectProvider , projectLocator ) ;
34
- var ex = Assert . Throws < ConventionFailedException > ( ( ) => Convention . Is ( new ProjectDoesNotReferenceDllsFromBinOrObjDirectories ( ) , project ) ) ;
35
-
36
- Approvals . Verify ( ex . Message ) ;
32
+ var failures = Convention . GetFailures ( new ProjectDoesNotReferenceDllsFromBinOrObjDirectories ( ) , project ) ;
33
+
34
+ failures . ShouldMatchApproved ( ) ;
37
35
}
38
36
39
37
[ Test ]
@@ -46,7 +44,9 @@ public void assemblies_referencing_bin_obj_with_approved_exceptions()
46
44
47
45
var projectLocator = Substitute . For < IProjectLocator > ( ) ;
48
46
var project = new ProjectReferences ( typeof ( ProjectBasedConventions ) . Assembly , projectProvider , projectLocator ) ;
49
- Convention . IsWithApprovedExeptions ( new ProjectDoesNotReferenceDllsFromBinOrObjDirectories ( ) , project ) ;
47
+ var failures = Convention . GetFailures ( new ProjectDoesNotReferenceDllsFromBinOrObjDirectories ( ) , project ) ;
48
+
49
+ failures . ShouldMatchApproved ( ) ;
50
50
}
51
51
52
52
[ Test ]
@@ -58,9 +58,9 @@ public void scripts_not_embedded_resources()
58
58
59
59
var projectLocator = Substitute . For < IProjectLocator > ( ) ;
60
60
var project = new ProjectFileItems ( typeof ( ProjectBasedConventions ) . Assembly , projectProvider , projectLocator ) ;
61
- var ex = Assert . Throws < ConventionFailedException > ( ( ) => Convention . Is ( new FilesAreEmbeddedResources ( ".sql" ) , project ) ) ;
61
+ var failures = Convention . GetFailures ( new FilesAreEmbeddedResources ( ".sql" ) , project ) ;
62
62
63
- Approvals . Verify ( ex . Message ) ;
63
+ failures . ShouldMatchApproved ( ) ;
64
64
}
65
65
66
66
[ Test ]
@@ -72,7 +72,7 @@ public void scripts_not_embedded_resources_with_approved_exceptions()
72
72
. LoadProjectDocument ( Arg . Any < string > ( ) )
73
73
. Returns ( XDocument . Parse ( Resources . ProjectFileWithInvalidSqlScriptFile ) ) ;
74
74
75
- Convention . IsWithApprovedExeptions ( new FilesAreEmbeddedResources ( ".sql" ) , project ) ;
75
+ Convention . GetFailures ( new FilesAreEmbeddedResources ( ".sql" ) , project ) ;
76
76
}
77
77
78
78
[ Test ]
@@ -84,11 +84,9 @@ public void release_debug_type_should_be_pdb_only()
84
84
85
85
var projectLocator = Substitute . For < IProjectLocator > ( ) ;
86
86
var propertyGroups = new ProjectPropertyGroups ( typeof ( ProjectBasedConventions ) . Assembly , projectProvider , projectLocator ) ;
87
- var ex =
88
- Assert . Throws < ConventionFailedException > (
89
- ( ) => Convention . Is ( new ConfigurationHasSpecificValue ( ConfigurationType . Release , "DebugType" , "pdbonly" ) , propertyGroups ) ) ;
87
+ var failures = Convention . GetFailures ( new ConfigurationHasSpecificValue ( ConfigurationType . Release , "DebugType" , "pdbonly" ) , propertyGroups ) ;
90
88
91
- Approvals . Verify ( ex . Message ) ;
89
+ failures . ShouldMatchApproved ( ) ;
92
90
}
93
91
94
92
[ Test ]
@@ -100,11 +98,9 @@ public void all_configuration_groups_should_have_platform_AnyCPU()
100
98
101
99
var projectLocator = Substitute . For < IProjectLocator > ( ) ;
102
100
var propertyGroups = new ProjectPropertyGroups ( typeof ( ProjectBasedConventions ) . Assembly , projectProvider , projectLocator ) ;
103
- var ex =
104
- Assert . Throws < ConventionFailedException > (
105
- ( ) => Convention . Is ( new ConfigurationHasSpecificValue ( ConfigurationType . All , "Platform" , "AnyCPU" ) , propertyGroups ) ) ;
101
+ var failures = Convention . GetFailures ( new ConfigurationHasSpecificValue ( ConfigurationType . All , "Platform" , "AnyCPU" ) , propertyGroups ) ;
106
102
107
- Approvals . Verify ( ex . Message ) ;
103
+ failures . ShouldMatchApproved ( ) ;
108
104
}
109
105
110
106
[ Test ]
@@ -116,11 +112,11 @@ public void all_configuration_groups_should_have_optimize_true_if_property_defin
116
112
117
113
var projectLocator = Substitute . For < IProjectLocator > ( ) ;
118
114
var propertyGroups = new ProjectPropertyGroups ( typeof ( ProjectBasedConventions ) . Assembly , projectProvider , projectLocator ) ;
119
- var ex =
120
- Assert . Throws < ConventionFailedException > (
121
- ( ) => Convention . Is ( new ConfigurationHasSpecificValue ( ConfigurationType . All , "Optimize" , "true" ) , propertyGroups ) ) ;
115
+ var failures =
116
+ Convention . GetFailures ( new ConfigurationHasSpecificValue ( ConfigurationType . All , "Optimize" , "true" ) ,
117
+ propertyGroups ) ;
122
118
123
- Approvals . Verify ( ex . Message ) ;
119
+ failures . ShouldMatchApproved ( ) ;
124
120
}
125
121
}
126
122
}
0 commit comments