@@ -69,7 +69,7 @@ protected async Task DocumentDBTest()
69
69
Assert . Equal ( doc . Id , id ) ;
70
70
}
71
71
72
- protected async Task NotificationHubTest ( )
72
+ protected async Task NotificationHubTest ( string functionName )
73
73
{
74
74
// NotificationHub tests need the following environment vars:
75
75
// "AzureWebJobsNotificationHubsConnectionString" -- the connection string for NotificationHubs
@@ -78,11 +78,27 @@ protected async Task NotificationHubTest()
78
78
{
79
79
{ "input" , "Hello" }
80
80
} ;
81
-
82
- //Only verifying the call succeeds. It is not possible to verify
83
- //actual push notificaiton is delivered as they are sent only to
84
- //client applications that registered with NotificationHubs
85
- await Fixture . Host . CallAsync ( "NotificationHubOut" , arguments ) ;
81
+
82
+ try
83
+ {
84
+ //Only verifying the call succeeds. It is not possible to verify
85
+ //actual push notificaiton is delivered as they are sent only to
86
+ //client applications that registered with NotificationHubs
87
+ await Fixture . Host . CallAsync ( functionName , arguments ) ;
88
+ }
89
+ catch ( Exception ex )
90
+ {
91
+ // Node: Check innerException, CSharp: check innerExcpetion.innerException
92
+ if ( VerifyNotificationHubExceptionMessage ( ex . InnerException )
93
+ || VerifyNotificationHubExceptionMessage ( ex . InnerException . InnerException ) )
94
+ {
95
+ //Expected if using NH without any registrations
96
+ }
97
+ else
98
+ {
99
+ throw ;
100
+ }
101
+ }
86
102
}
87
103
88
104
protected async Task EasyTablesTest ( bool writeToQueue = true )
@@ -197,5 +213,16 @@ protected static string RemoveByteOrderMarkAndWhitespace(string s)
197
213
string byteOrderMark = Encoding . UTF8 . GetString ( Encoding . UTF8 . GetPreamble ( ) ) ;
198
214
return s . Trim ( ) . Replace ( " " , string . Empty ) . Replace ( byteOrderMark , string . Empty ) ;
199
215
}
216
+
217
+ protected static bool VerifyNotificationHubExceptionMessage ( Exception exception )
218
+ {
219
+ if ( ( exception . Source == "Microsoft.Azure.NotificationHubs" )
220
+ && exception . Message . Contains ( "notification has no target applications" ) )
221
+ {
222
+ //Expected if using NH without any registrations
223
+ return true ;
224
+ }
225
+ return false ;
226
+ }
200
227
}
201
228
}
0 commit comments