Example #1
0
        public NotificationService(IEnumerable <VariableMessageSign> liveData, string subscriptionsPath, WebPushNotification webPushNotificationSettings, string webUrl)
        {
            _liveData          = liveData;
            _subscriptionsPath = Path.Combine(subscriptionsPath, "userSubscriptions.json");

            _pushUsers                   = ReadJsonFromFile <PushUser>(_subscriptionsPath).Result;
            _lastSentNotifications       = ReadJsonFromFile <PushUser>(_subscriptionsPath).Result;
            _webPushNotificationSettings = webPushNotificationSettings;
            _webUrl = webUrl;
        }
Example #2
0
        public void Firefox_Notification_Should_Throw_Error_If_Payload_Exceed_Limit()
        {
            var settings = Settings.Instance;
            var ctx      = new BrokerContext();

            ctx.Start();

            var subsription = settings.WebPush.FirefoxSubscription;

            var notif = new WebPushNotification(subsription);
            var value = new string('a', 1024 * 5);

            notif.Payload = JObject.Parse($"{{ \"somekey\" : \"{value}\" }}");
            ctx.Broker.QueueNotification(notif);

            ctx.Broker.Stop();

            ctx.AssertPayloadExceedLimit();
        }
Example #3
0
        public void Firefox_Notification_With_Payload_Test()
        {
            var settings = Settings.Instance;
            var ctx      = new BrokerContext();

            ctx.Start();

            var subsription = settings.WebPush.FirefoxSubscription;

            var notif = new WebPushNotification(subsription);

            notif.Payload = JObject.Parse("{ \"somekey\" : \"somevalue\" }");
            ctx.Broker.QueueNotification(notif);

            ctx.Broker.Stop();

            Assert.AreEqual(1, ctx.Succeeded);
            Assert.AreEqual(0, ctx.Failed);
        }
Example #4
0
        public void Chrome_Should_Throw_Correct_Error_For_OutDated_Subscription()
        {
            var settings = Settings.Instance;
            var ctx      = new BrokerContext();

            ctx.Start();

            var subsription = settings.WebPush.ChromeOutdatedSubscription;

            var notif = new WebPushNotification(subsription);

            notif.Payload = JObject.Parse("{ \"somekey\" : \"somevalue\" }");
            ctx.Broker.QueueNotification(notif);

            ctx.Broker.Stop();

            Assert.AreEqual(0, ctx.Succeeded);
            ctx.AssertSubscriptionExpired();
        }
Example #5
0
 public WebPushNotificationException(WebPushNotification notification, string msg, string description)
     : base(msg, notification)
 {
     Notification = notification;
     Description  = description;
 }