@@ -69,7 +69,7 @@ protected async Task DocumentDBTest()
6969 Assert . Equal ( doc . Id , id ) ;
7070 }
7171
72- protected async Task NotificationHubTest ( )
72+ protected async Task NotificationHubTest ( string functionName )
7373 {
7474 // NotificationHub tests need the following environment vars:
7575 // "AzureWebJobsNotificationHubsConnectionString" -- the connection string for NotificationHubs
@@ -78,11 +78,27 @@ protected async Task NotificationHubTest()
7878 {
7979 { "input" , "Hello" }
8080 } ;
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+ }
86102 }
87103
88104 protected async Task EasyTablesTest ( bool writeToQueue = true )
@@ -197,5 +213,16 @@ protected static string RemoveByteOrderMarkAndWhitespace(string s)
197213 string byteOrderMark = Encoding . UTF8 . GetString ( Encoding . UTF8 . GetPreamble ( ) ) ;
198214 return s . Trim ( ) . Replace ( " " , string . Empty ) . Replace ( byteOrderMark , string . Empty ) ;
199215 }
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+ }
200227 }
201228}
0 commit comments