@@ -7,87 +7,87 @@ namespace WebPush.Test
77{
88 public class WebPushClientTest
99 {
10- private const string TEST_PUBLIC_KEY =
10+ private const string TestPublicKey =
1111 @"BCvKwB2lbVUYMFAaBUygooKheqcEU-GDrVRnu8k33yJCZkNBNqjZj0VdxQ2QIZa4kV5kpX9aAqyBKZHURm6eG1A" ;
1212
13- private const string TEST_PRIVATE_KEY = @"on6X5KmLEFIVvPP3cNX9kE0OF6PV9TJQXVbnKU2xEHI" ;
13+ private const string TestPrivateKey = @"on6X5KmLEFIVvPP3cNX9kE0OF6PV9TJQXVbnKU2xEHI" ;
1414
15- private const string TEST_GCM_ENDPOINT = @"https://android.googleapis.com/gcm/send/" ;
15+ private const string TestGcmEndpoint = @"https://android.googleapis.com/gcm/send/" ;
1616
17- private const string TEST_FCM_ENDPOINT =
17+ private const string TestFcmEndpoint =
1818 @"https://fcm.googleapis.com/fcm/send/efz_TLX_rLU:APA91bE6U0iybLYvv0F3mf6" ;
1919
2020 [ Fact ]
21- public void TestGCMAPIKeyInOptions ( )
21+ public void TestGcmApiKeyInOptions ( )
2222 {
2323 var client = new WebPushClient ( ) ;
2424
2525 var gcmAPIKey = @"teststring" ;
26- var subscription = new PushSubscription ( TEST_GCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
26+ var subscription = new PushSubscription ( TestGcmEndpoint , TestPublicKey , TestPrivateKey ) ;
2727
2828 var options = new Dictionary < string , object > ( ) ;
29- options [ "gcmAPIKey" ] = gcmAPIKey ;
30- var message = client . GenerateRequestDetails ( subscription , "test payload" , options ) ;
31- var authorizationHeader = message . Headers . GetValues ( "Authorization" ) . First ( ) ;
29+ options [ @ "gcmAPIKey"] = gcmAPIKey ;
30+ var message = client . GenerateRequestDetails ( subscription , @ "test payload", options ) ;
31+ var authorizationHeader = message . Headers . GetValues ( @ "Authorization") . First ( ) ;
3232
3333 Assert . Equal ( "key=" + gcmAPIKey , authorizationHeader ) ;
3434
3535 // Test previous incorrect casing of gcmAPIKey
3636 var options2 = new Dictionary < string , object > ( ) ;
37- options2 [ "gcmApiKey" ] = gcmAPIKey ;
37+ options2 [ @ "gcmApiKey"] = gcmAPIKey ;
3838 Assert . Throws < ArgumentException > ( delegate
3939 {
4040 client . GenerateRequestDetails ( subscription , "test payload" , options2 ) ;
4141 } ) ;
4242 }
4343
4444 [ Fact ]
45- public void TestSetGCMAPIKey ( )
45+ public void TestSetGcmApiKey ( )
4646 {
4747 var client = new WebPushClient ( ) ;
4848
4949 var gcmAPIKey = @"teststring" ;
50- client . SetGCMAPIKey ( gcmAPIKey ) ;
51- var subscription = new PushSubscription ( TEST_GCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
52- var message = client . GenerateRequestDetails ( subscription , "test payload" ) ;
53- var authorizationHeader = message . Headers . GetValues ( "Authorization" ) . First ( ) ;
50+ client . SetGcmApiKey ( gcmAPIKey ) ;
51+ var subscription = new PushSubscription ( TestGcmEndpoint , TestPublicKey , TestPrivateKey ) ;
52+ var message = client . GenerateRequestDetails ( subscription , @ "test payload") ;
53+ var authorizationHeader = message . Headers . GetValues ( @ "Authorization") . First ( ) ;
5454
55- Assert . Equal ( "key=" + gcmAPIKey , authorizationHeader ) ;
55+ Assert . Equal ( @ "key=" + gcmAPIKey , authorizationHeader ) ;
5656 }
5757
5858 [ Fact ]
59- public void TestSetGCMAPIKeyEmptyString ( )
59+ public void TestSetGcmApiKeyEmptyString ( )
6060 {
6161 var client = new WebPushClient ( ) ;
6262
63- Assert . Throws ( typeof ( ArgumentException ) , delegate { client . SetGCMAPIKey ( "" ) ; } ) ;
63+ Assert . Throws ( typeof ( ArgumentException ) , delegate { client . SetGcmApiKey ( "" ) ; } ) ;
6464 }
6565
6666 [ Fact ]
67- public void TestSetGCMAPiKeyNonGCMPushService ( )
67+ public void TestSetGcmApiKeyNonGcmPushService ( )
6868 {
6969 // Ensure that the API key doesn't get added on a service that doesn't accept it.
7070 var client = new WebPushClient ( ) ;
7171
7272 var gcmAPIKey = @"teststring" ;
73- client . SetGCMAPIKey ( gcmAPIKey ) ;
74- var subscription = new PushSubscription ( TEST_FCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
75- var message = client . GenerateRequestDetails ( subscription , "test payload" ) ;
73+ client . SetGcmApiKey ( gcmAPIKey ) ;
74+ var subscription = new PushSubscription ( TestFcmEndpoint , TestPublicKey , TestPrivateKey ) ;
75+ var message = client . GenerateRequestDetails ( subscription , @ "test payload") ;
7676
7777 IEnumerable < string > values ;
78- Assert . False ( message . Headers . TryGetValues ( "Authorization" , out values ) ) ;
78+ Assert . False ( message . Headers . TryGetValues ( @ "Authorization", out values ) ) ;
7979 }
8080
8181 [ Fact ]
82- public void TestSetGCMAPIKeyNull ( )
82+ public void TestSetGcmApiKeyNull ( )
8383 {
8484 var client = new WebPushClient ( ) ;
8585
86- client . SetGCMAPIKey ( @"somestring" ) ;
87- client . SetGCMAPIKey ( null ) ;
86+ client . SetGcmApiKey ( @"somestring" ) ;
87+ client . SetGcmApiKey ( null ) ;
8888
89- var subscription = new PushSubscription ( TEST_GCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
90- var message = client . GenerateRequestDetails ( subscription , "test payload" ) ;
89+ var subscription = new PushSubscription ( TestGcmEndpoint , TestPublicKey , TestPrivateKey ) ;
90+ var message = client . GenerateRequestDetails ( subscription , @ "test payload") ;
9191
9292 IEnumerable < string > values ;
9393 Assert . False ( message . Headers . TryGetValues ( "Authorization" , out values ) ) ;
@@ -98,15 +98,15 @@ public void TestSetVapidDetails()
9898 {
9999 var client = new WebPushClient ( ) ;
100100
101- client . SetVapidDetails ( "mailto:[email protected] " , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ; 101+ client . SetVapidDetails ( "mailto:[email protected] " , TestPublicKey , TestPrivateKey ) ; 102102
103- var subscription = new PushSubscription ( TEST_FCM_ENDPOINT , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
104- var message = client . GenerateRequestDetails ( subscription , "test payload" ) ;
105- var authorizationHeader = message . Headers . GetValues ( "Authorization" ) . First ( ) ;
106- var cryptoHeader = message . Headers . GetValues ( "Crypto-Key" ) . First ( ) ;
103+ var subscription = new PushSubscription ( TestFcmEndpoint , TestPublicKey , TestPrivateKey ) ;
104+ var message = client . GenerateRequestDetails ( subscription , @ "test payload") ;
105+ var authorizationHeader = message . Headers . GetValues ( @ "Authorization") . First ( ) ;
106+ var cryptoHeader = message . Headers . GetValues ( @ "Crypto-Key") . First ( ) ;
107107
108- Assert . True ( authorizationHeader . StartsWith ( "WebPush " ) ) ;
109- Assert . True ( cryptoHeader . Contains ( "p256ecdsa" ) ) ;
108+ Assert . True ( authorizationHeader . StartsWith ( @ "WebPush ") ) ;
109+ Assert . True ( cryptoHeader . Contains ( @ "p256ecdsa") ) ;
110110 }
111111 }
112112}
0 commit comments