@@ -7,87 +7,87 @@ namespace WebPush.Test
7
7
{
8
8
public class WebPushClientTest
9
9
{
10
- private const string TEST_PUBLIC_KEY =
10
+ private const string TestPublicKey =
11
11
@"BCvKwB2lbVUYMFAaBUygooKheqcEU-GDrVRnu8k33yJCZkNBNqjZj0VdxQ2QIZa4kV5kpX9aAqyBKZHURm6eG1A" ;
12
12
13
- private const string TEST_PRIVATE_KEY = @"on6X5KmLEFIVvPP3cNX9kE0OF6PV9TJQXVbnKU2xEHI" ;
13
+ private const string TestPrivateKey = @"on6X5KmLEFIVvPP3cNX9kE0OF6PV9TJQXVbnKU2xEHI" ;
14
14
15
- private const string TEST_GCM_ENDPOINT = @"https://android.googleapis.com/gcm/send/" ;
15
+ private const string TestGcmEndpoint = @"https://android.googleapis.com/gcm/send/" ;
16
16
17
- private const string TEST_FCM_ENDPOINT =
17
+ private const string TestFcmEndpoint =
18
18
@"https://fcm.googleapis.com/fcm/send/efz_TLX_rLU:APA91bE6U0iybLYvv0F3mf6" ;
19
19
20
20
[ Fact ]
21
- public void TestGCMAPIKeyInOptions ( )
21
+ public void TestGcmApiKeyInOptions ( )
22
22
{
23
23
var client = new WebPushClient ( ) ;
24
24
25
25
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 ) ;
27
27
28
28
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 ( ) ;
32
32
33
33
Assert . Equal ( "key=" + gcmAPIKey , authorizationHeader ) ;
34
34
35
35
// Test previous incorrect casing of gcmAPIKey
36
36
var options2 = new Dictionary < string , object > ( ) ;
37
- options2 [ "gcmApiKey" ] = gcmAPIKey ;
37
+ options2 [ @ "gcmApiKey"] = gcmAPIKey ;
38
38
Assert . Throws < ArgumentException > ( delegate
39
39
{
40
40
client . GenerateRequestDetails ( subscription , "test payload" , options2 ) ;
41
41
} ) ;
42
42
}
43
43
44
44
[ Fact ]
45
- public void TestSetGCMAPIKey ( )
45
+ public void TestSetGcmApiKey ( )
46
46
{
47
47
var client = new WebPushClient ( ) ;
48
48
49
49
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 ( ) ;
54
54
55
- Assert . Equal ( "key=" + gcmAPIKey , authorizationHeader ) ;
55
+ Assert . Equal ( @ "key=" + gcmAPIKey , authorizationHeader ) ;
56
56
}
57
57
58
58
[ Fact ]
59
- public void TestSetGCMAPIKeyEmptyString ( )
59
+ public void TestSetGcmApiKeyEmptyString ( )
60
60
{
61
61
var client = new WebPushClient ( ) ;
62
62
63
- Assert . Throws ( typeof ( ArgumentException ) , delegate { client . SetGCMAPIKey ( "" ) ; } ) ;
63
+ Assert . Throws ( typeof ( ArgumentException ) , delegate { client . SetGcmApiKey ( "" ) ; } ) ;
64
64
}
65
65
66
66
[ Fact ]
67
- public void TestSetGCMAPiKeyNonGCMPushService ( )
67
+ public void TestSetGcmApiKeyNonGcmPushService ( )
68
68
{
69
69
// Ensure that the API key doesn't get added on a service that doesn't accept it.
70
70
var client = new WebPushClient ( ) ;
71
71
72
72
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") ;
76
76
77
77
IEnumerable < string > values ;
78
- Assert . False ( message . Headers . TryGetValues ( "Authorization" , out values ) ) ;
78
+ Assert . False ( message . Headers . TryGetValues ( @ "Authorization", out values ) ) ;
79
79
}
80
80
81
81
[ Fact ]
82
- public void TestSetGCMAPIKeyNull ( )
82
+ public void TestSetGcmApiKeyNull ( )
83
83
{
84
84
var client = new WebPushClient ( ) ;
85
85
86
- client . SetGCMAPIKey ( @"somestring" ) ;
87
- client . SetGCMAPIKey ( null ) ;
86
+ client . SetGcmApiKey ( @"somestring" ) ;
87
+ client . SetGcmApiKey ( null ) ;
88
88
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") ;
91
91
92
92
IEnumerable < string > values ;
93
93
Assert . False ( message . Headers . TryGetValues ( "Authorization" , out values ) ) ;
@@ -98,15 +98,15 @@ public void TestSetVapidDetails()
98
98
{
99
99
var client = new WebPushClient ( ) ;
100
100
101
- client . SetVapidDetails ( "mailto:example@example.com" , TEST_PUBLIC_KEY , TEST_PRIVATE_KEY ) ;
101
+ client . SetVapidDetails ( "mailto:example@example.com" , TestPublicKey , TestPrivateKey ) ;
102
102
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 ( ) ;
107
107
108
- Assert . True ( authorizationHeader . StartsWith ( "WebPush " ) ) ;
109
- Assert . True ( cryptoHeader . Contains ( "p256ecdsa" ) ) ;
108
+ Assert . True ( authorizationHeader . StartsWith ( @ "WebPush ") ) ;
109
+ Assert . True ( cryptoHeader . Contains ( @ "p256ecdsa") ) ;
110
110
}
111
111
}
112
112
}
0 commit comments