You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix Should-Throw/Should -Throw to handle expected message with escaped wildcard (#2559)
* Fix Should-Throw to handle expected message with escaped wildcard
* Fix Should -Throw to handle expected message with escaped wildcard
* Fix other tests to test for word 'like'
* Correctly pass value to Format-Nicely
* Fix escaping outside of string
* Fix missing part in one test
* Fix test to call -replace correctly
* Fix test similar to other
$failureMessage="Expected no exception to be thrown,$(Format-Because$Because) but an exception `"$actualExceptionMessage`" was thrown $actualExceptionLine."
$err.Exception.Message| Verify-Equal "Expected an exception, of type [InvalidOperationException], with message 'halt!' to be thrown, but the exception type was [ArgumentException] and the message was 'fail!'."
103
+
$err.Exception.Message| Verify-Equal "Expected an exception, of type [InvalidOperationException], with message like 'halt!' to be thrown, but the exception type was [ArgumentException] and the message was 'fail!'."
100
104
}
101
105
102
106
It "Given exception that does not match on type and FullyQualifiedErrorId it returns the correct message" {
@@ -106,12 +110,17 @@ Describe "Should-Throw" {
106
110
107
111
It "Given exception that does not match on message and FullyQualifiedErrorId it returns the correct message" {
$err.Exception.Message| Verify-Equal "Expected an exception, with message 'fail!', with FullyQualifiedErrorId 'fail!' to be thrown, but the message was 'halt!' and the FullyQualifiedErrorId was 'halt!'."
113
+
$err.Exception.Message| Verify-Equal "Expected an exception, with message like 'fail!', with FullyQualifiedErrorId 'fail!' to be thrown, but the message was 'halt!' and the FullyQualifiedErrorId was 'halt!'."
110
114
}
111
115
112
116
It "Given exception that does not match on type, message and FullyQualifiedErrorId it returns the correct message" {
$err.Exception.Message| Verify-Equal "Expected an exception, of type [InvalidOperationException], with message 'fail!' and with FullyQualifiedErrorId 'fail!' to be thrown, but the exception type was [ArgumentException], the message was 'halt!' and the FullyQualifiedErrorId was 'halt!'."
118
+
$err.Exception.Message| Verify-Equal "Expected an exception, of type [InvalidOperationException], with message like 'fail!' and with FullyQualifiedErrorId 'fail!' to be thrown, but the exception type was [ArgumentException], the message was 'halt!' and the FullyQualifiedErrorId was 'halt!'."
119
+
}
120
+
121
+
It "Given exception that does not match on a message with escaped wildcard it returns the correct message" {
# use the real path of the script, because we don't know it beforehand
173
+
$assertionMessage="Expected an exception with message like '[]' to be thrown, but the message was '[!]'. from ##path##:1 char:"-replace"##path##",$testScriptPath
0 commit comments