@@ -28,13 +28,37 @@ public void TestSetGCMAPIKey()
2828 {
2929 WebPushClient client = new WebPushClient ( ) ;
3030
31- string gcmApiKey = @"teststring" ;
32- client . SetGCMAPIKey ( gcmApiKey ) ;
31+ string gcmAPIKey = @"teststring" ;
32+ client . SetGCMAPIKey ( gcmAPIKey ) ;
3333 PushSubscription subscription = new PushSubscription ( TEST_GCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
3434 HttpRequestMessage message = client . GenerateRequestDetails ( subscription , "test payload" ) ;
3535 string authorizationHeader = message . Headers . GetValues ( "Authorization" ) . First ( ) ;
3636
37- Assert . AreEqual ( "key=" + gcmApiKey , authorizationHeader ) ;
37+ Assert . AreEqual ( "key=" + gcmAPIKey , authorizationHeader ) ;
38+ }
39+
40+ [ Test ]
41+ public void TestGCMAPIKeyInOptions ( )
42+ {
43+ WebPushClient client = new WebPushClient ( ) ;
44+
45+ string gcmAPIKey = @"teststring" ;
46+ PushSubscription subscription = new PushSubscription ( TEST_GCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
47+
48+ Dictionary < string , object > options = new Dictionary < string , object > ( ) ;
49+ options [ "gcmAPIKey" ] = gcmAPIKey ;
50+ HttpRequestMessage message = client . GenerateRequestDetails ( subscription , "test payload" , options ) ;
51+ string authorizationHeader = message . Headers . GetValues ( "Authorization" ) . First ( ) ;
52+
53+ Assert . AreEqual ( "key=" + gcmAPIKey , authorizationHeader ) ;
54+
55+ // Test previous incorrect casing of gcmAPIKey
56+ Dictionary < string , object > options2 = new Dictionary < string , object > ( ) ;
57+ options2 [ "gcmApiKey" ] = gcmAPIKey ;
58+ Assert . Throws < ArgumentException > ( delegate
59+ {
60+ client . GenerateRequestDetails ( subscription , "test payload" , options2 ) ;
61+ } ) ;
3862 }
3963
4064 [ Test ]
@@ -69,8 +93,8 @@ public void TestSetGCMAPiKeyNonGCMPushService()
6993 // Ensure that the API key doesn't get added on a service that doesn't accept it.
7094 WebPushClient client = new WebPushClient ( ) ;
7195
72- string gcmApiKey = @"teststring" ;
73- client . SetGCMAPIKey ( gcmApiKey ) ;
96+ string gcmAPIKey = @"teststring" ;
97+ client . SetGCMAPIKey ( gcmAPIKey ) ;
7498 PushSubscription subscription = new PushSubscription ( TEST_FCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
7599 HttpRequestMessage message = client . GenerateRequestDetails ( subscription , "test payload" ) ;
76100
0 commit comments