File tree 7 files changed +17
-12
lines changed
NHSpecificTest/NH1274ExportExclude
Tools/hbm2ddl/SchemaValidator
NHSpecificTest/NH1274ExportExclude
Tools/hbm2ddl/SchemaValidator
7 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ public void SchemaExport_Validate_CausesValidateExceptionAsync()
95
95
Assert . That (
96
96
( ) => validator . ValidateAsync ( ) ,
97
97
Throws . TypeOf < SchemaValidationException > ( )
98
- . And . Message . EqualTo ( "Schema validation failed: see list of validation errors" )
98
+ . And . Message . StartsWith ( "Schema validation failed: see list of validation errors" )
99
99
. And . Property ( "ValidationErrors" ) . Contains ( "Missing table: Home_Validate" ) ) ;
100
100
}
101
101
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public async Task ShouldBeInvalidIfTimestampTzIsExpectedAndGotTimestampAsync()
37
37
var validator = new Tool . hbm2ddl . SchemaValidator ( expected ) ;
38
38
39
39
var error = Assert . ThrowsAsync < SchemaValidationException > ( ( ) => validator . ValidateAsync ( ) ) ;
40
- Assert . That ( error , Has . Message . EqualTo ( "Schema validation failed: see list of validation errors" ) ) ;
40
+ Assert . That ( error , Has . Message . StartsWith ( "Schema validation failed: see list of validation errors" ) ) ;
41
41
Assert . That (
42
42
error ,
43
43
Has . Property ( "ValidationErrors" ) . Some . Contains ( "Wrong column type" ) . IgnoreCase
@@ -65,7 +65,7 @@ public async Task ShouldBeInvalidIfTimestampIsExpectedAndGotTimestampTzAsync()
65
65
var validator = new Tool . hbm2ddl . SchemaValidator ( expected ) ;
66
66
67
67
var error = Assert . ThrowsAsync < SchemaValidationException > ( ( ) => validator . ValidateAsync ( ) ) ;
68
- Assert . That ( error , Has . Message . EqualTo ( "Schema validation failed: see list of validation errors" ) ) ;
68
+ Assert . That ( error , Has . Message . StartsWith ( "Schema validation failed: see list of validation errors" ) ) ;
69
69
Assert . That (
70
70
error ,
71
71
Has . Property ( "ValidationErrors" ) . Some . Contains ( "Wrong column type" ) . IgnoreCase
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public void ShouldNotVerifyModifiedTableAsync()
90
90
Assert . That (
91
91
( ) => validatorV2 . ValidateAsync ( ) ,
92
92
Throws . TypeOf < SchemaValidationException > ( )
93
- . And . Message . EqualTo ( "Schema validation failed: see list of validation errors" )
93
+ . And . Message . StartsWith ( "Schema validation failed: see list of validation errors" )
94
94
. And . Property ( "ValidationErrors" ) . Some . Contains ( "Missing column: Name in " ) . IgnoreCase . And . Contains ( "Version" ) . IgnoreCase ) ;
95
95
}
96
96
@@ -103,7 +103,7 @@ public void ShouldNotVerifyMultiModifiedTableAsync()
103
103
104
104
var error = Assert . ThrowsAsync < SchemaValidationException > ( ( ) => validator . ValidateAsync ( ) ) ;
105
105
Assert . That ( error ,
106
- Has . Message . EqualTo ( "Schema validation failed: see list of validation errors" )
106
+ Has . Message . StartsWith ( "Schema validation failed: see list of validation errors" )
107
107
. And . Property ( "ValidationErrors" ) . Some . Contains ( "Missing column: Name in " ) . IgnoreCase . And . Contains ( "Version" ) . IgnoreCase ) ;
108
108
Assert . That ( error ,
109
109
Has . Property ( "ValidationErrors" ) . Some . Contains ( "Missing column: Title in " ) . IgnoreCase . And . Contains ( "Version" ) . IgnoreCase ) ;
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ public void SchemaExport_Validate_CausesValidateException()
84
84
Assert . That (
85
85
( ) => validator . Validate ( ) ,
86
86
Throws . TypeOf < SchemaValidationException > ( )
87
- . And . Message . EqualTo ( "Schema validation failed: see list of validation errors" )
87
+ . And . Message . StartsWith ( "Schema validation failed: see list of validation errors" )
88
88
. And . Property ( "ValidationErrors" ) . Contains ( "Missing table: Home_Validate" ) ) ;
89
89
}
90
90
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public void ShouldBeInvalidIfTimestampTzIsExpectedAndGotTimestamp()
26
26
var validator = new Tool . hbm2ddl . SchemaValidator ( expected ) ;
27
27
28
28
var error = Assert . Throws < SchemaValidationException > ( ( ) => validator . Validate ( ) ) ;
29
- Assert . That ( error , Has . Message . EqualTo ( "Schema validation failed: see list of validation errors" ) ) ;
29
+ Assert . That ( error , Has . Message . StartsWith ( "Schema validation failed: see list of validation errors" ) ) ;
30
30
Assert . That (
31
31
error ,
32
32
Has . Property ( "ValidationErrors" ) . Some . Contains ( "Wrong column type" ) . IgnoreCase
@@ -54,7 +54,7 @@ public void ShouldBeInvalidIfTimestampIsExpectedAndGotTimestampTz()
54
54
var validator = new Tool . hbm2ddl . SchemaValidator ( expected ) ;
55
55
56
56
var error = Assert . Throws < SchemaValidationException > ( ( ) => validator . Validate ( ) ) ;
57
- Assert . That ( error , Has . Message . EqualTo ( "Schema validation failed: see list of validation errors" ) ) ;
57
+ Assert . That ( error , Has . Message . StartsWith ( "Schema validation failed: see list of validation errors" ) ) ;
58
58
Assert . That (
59
59
error ,
60
60
Has . Property ( "ValidationErrors" ) . Some . Contains ( "Wrong column type" ) . IgnoreCase
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public void ShouldNotVerifyModifiedTable()
79
79
Assert . That (
80
80
( ) => validatorV2 . Validate ( ) ,
81
81
Throws . TypeOf < SchemaValidationException > ( )
82
- . And . Message . EqualTo ( "Schema validation failed: see list of validation errors" )
82
+ . And . Message . StartsWith ( "Schema validation failed: see list of validation errors" )
83
83
. And . Property ( "ValidationErrors" ) . Some . Contains ( "Missing column: Name in " ) . IgnoreCase . And . Contains ( "Version" ) . IgnoreCase ) ;
84
84
}
85
85
@@ -92,7 +92,7 @@ public void ShouldNotVerifyMultiModifiedTable()
92
92
93
93
var error = Assert . Throws < SchemaValidationException > ( ( ) => validator . Validate ( ) ) ;
94
94
Assert . That ( error ,
95
- Has . Message . EqualTo ( "Schema validation failed: see list of validation errors" )
95
+ Has . Message . StartsWith ( "Schema validation failed: see list of validation errors" )
96
96
. And . Property ( "ValidationErrors" ) . Some . Contains ( "Missing column: Name in " ) . IgnoreCase . And . Contains ( "Version" ) . IgnoreCase ) ;
97
97
Assert . That ( error ,
98
98
Has . Property ( "ValidationErrors" ) . Some . Contains ( "Missing column: Title in " ) . IgnoreCase . And . Contains ( "Version" ) . IgnoreCase ) ;
Original file line number Diff line number Diff line change 3
3
using System . Collections . ObjectModel ;
4
4
using System . Runtime . Serialization ;
5
5
using System . Security ;
6
+ using System . Text ;
6
7
7
8
namespace NHibernate
8
9
{
@@ -36,8 +37,12 @@ public override string Message
36
37
var message = base . Message ;
37
38
if ( ValidationErrors == null || ValidationErrors . Count == 0 )
38
39
return message ;
39
- var errors = "ValidationErrors:" + string . Join ( Environment . NewLine + "- " , ValidationErrors ) ;
40
- return message + Environment . NewLine + errors ;
40
+
41
+ var sb = new StringBuilder ( message ) . AppendLine ( ) . AppendLine ( "Validation errors:" ) ;
42
+ foreach ( var error in ValidationErrors )
43
+ sb . Append ( '-' ) . AppendLine ( error ) ;
44
+
45
+ return sb . ToString ( ) ;
41
46
}
42
47
}
43
48
}
You can’t perform that action at this time.
0 commit comments