Beispiel #1
0
        public void TestSetGCMAPIKeyNull()
        {
            WebPushClient client = new WebPushClient();

            client.SetGCMAPIKey(@"somestring");
            client.SetGCMAPIKey(null);

            PushSubscription   subscription = new PushSubscription(TEST_GCM_ENDPOINT, TEST_PUBLIC_KEY, TEST_PRIVATE_KEY);
            HttpRequestMessage message      = client.GenerateRequestDetails(subscription, "test payload");

            IEnumerable <string> values;

            Assert.False(message.Headers.TryGetValues("Authorization", out values));
        }
Beispiel #2
0
        public void TestSetGCMAPIKeyEmptyString()
        {
            WebPushClient client = new WebPushClient();

            Assert.Throws(typeof(ArgumentException), delegate
            {
                client.SetGCMAPIKey("");
            });
        }
Beispiel #3
0
        public void TestSetGCMAPIKey()
        {
            WebPushClient client = new WebPushClient();

            string gcmAPIKey = @"teststring";

            client.SetGCMAPIKey(gcmAPIKey);
            PushSubscription   subscription        = new PushSubscription(TEST_GCM_ENDPOINT, TEST_PUBLIC_KEY, TEST_PRIVATE_KEY);
            HttpRequestMessage message             = client.GenerateRequestDetails(subscription, "test payload");
            string             authorizationHeader = message.Headers.GetValues("Authorization").First();

            Assert.AreEqual("key=" + gcmAPIKey, authorizationHeader);
        }
Beispiel #4
0
        public void TestSetGCMAPiKeyNonGCMPushService()
        {
            // Ensure that the API key doesn't get added on a service that doesn't accept it.
            WebPushClient client = new WebPushClient();

            string gcmAPIKey = @"teststring";

            client.SetGCMAPIKey(gcmAPIKey);
            PushSubscription   subscription = new PushSubscription(TEST_FCM_ENDPOINT, TEST_PUBLIC_KEY, TEST_PRIVATE_KEY);
            HttpRequestMessage message      = client.GenerateRequestDetails(subscription, "test payload");

            IEnumerable <string> values;

            Assert.False(message.Headers.TryGetValues("Authorization", out values));
        }