コード例 #1
0
    public void Simple()
    {
        var service = new PushService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
        var request = new PushNotificationRequest
            {
                DeviceTokens = new List<string>
                    {
                        "BadToken"
                    },
                Payload = new PushPayload
                    {
                        Alert = "Alert"
                    },
            };

        Exception exception = null;
        try
        {

            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(request, respone => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
        catch (Exception e)
        {
            exception = e;
        }

        var remoteException = exception as RemoteException;
        Assert.IsNotNull(remoteException);
        Assert.AreEqual("{\"error_code\": 40001, \"details\": {\"device_tokens.0.device_token\": [\"device_token contains an invalid device token: BADTOKEN\"]}, \"error\": \"Data validation error\"}", remoteException.Message);
    }
コード例 #2
0
        public void Simple()
        {
            var service = new PushService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var pushNotification = new PushNotificationRequest
            {
                DeviceTokens = new List <string>
                {
                    RemoteSettings.AppleDeviceId
                },
                Payload = new PushPayload
                {
                    Alert = "Alert"
                },
                CustomData = new Dictionary <string, string>
                {
                    { "Key", "Value" }
                }
            };

            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(pushNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #3
0
        public void Simple()
        {
            var service = new PushService
                {
                    RequestBuilder = RequestBuilderHelper.Build()
                };
            var pushNotification = new PushNotificationRequest
                {
                    DeviceTokens = new List<string>
                        {
                            RemoteSettings.AppleDeviceId
                        },
                    Payload = new PushPayload
                        {
                            Alert = "Alert"
                        },
                    CustomData = new Dictionary<string, string>
                        {
                         {"Key", "Value"}
                        }
                };

            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(pushNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #4
0
        public void Tags()
        {
            var service = new DeleteTagService
                              {
                                  RequestBuilder = RequestBuilderHelper.Build()
                              };

            var helper = new AsyncTestHelper();
            var request = new DeleteTagRequest {Tag = "myTag"};
            service.Execute(request, response => helper.Callback(null), helper.HandleException);
            helper.Wait();
        }
コード例 #5
0
        public void Tags()
        {
            var service = new DeleteTagService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };

            var helper  = new AsyncTestHelper();
            var request = new DeleteTagRequest {
                Tag = "myTag"
            };

            service.Execute(request, response => helper.Callback(null), helper.HandleException);
            helper.Wait();
        }
コード例 #6
0
        public void Tags()
        {
            var service = new AddRegistrationService
                              {
                                  RequestBuilder = RequestBuilderHelper.Build()
                              };
            var registration = new AddRegistrationRequest
                                   {
                                       PushId = RemoteSettings.AndroidPushId,
                                       Tags = new List<string> {"bangladesh"}
                                   };

            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(registration, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #7
0
        public void Tags()
        {
            var service = new RemoveTagFromDeviceService
                              {
                                  RequestBuilder = RequestBuilderHelper.Build()
                              };

            var helper = new AsyncTestHelper();
            var request = new RemoveTagFromDeviceRequest
                              {
                                  DeviceToken = "DeviceId",
                                  TagToRemove = "tag1434"
                              };
            service.Execute(request, response => helper.Callback(null), helper.HandleException);
            helper.Wait();
        }
コード例 #8
0
        public void TagToDevice()
        {
            var service = new AddTagToDeviceService
                              {
                                  RequestBuilder = RequestBuilderHelper.Build()
                              };

            var asyncTestHelper = new AsyncTestHelper();
            var request = new AddTagToDeviceRequest
                              {
                                  DeviceToken = RemoteSettings.AppleDeviceId,
                                  Tag = "africa"
                              };
            service.Execute(request, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #9
0
        public void TagToDevice()
        {
            var service = new AddTagToDeviceService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };

            var asyncTestHelper = new AsyncTestHelper();
            var request         = new AddTagToDeviceRequest
            {
                DeviceToken = RemoteSettings.AppleDeviceId,
                Tag         = "africa"
            };

            service.Execute(request, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #10
0
        public void Tags()
        {
            var service = new RemoveTagFromDeviceService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };

            var helper  = new AsyncTestHelper();
            var request = new RemoveTagFromDeviceRequest
            {
                DeviceToken = "DeviceId",
                TagToRemove = "tag1434"
            };

            service.Execute(request, response => helper.Callback(null), helper.HandleException);
            helper.Wait();
        }
コード例 #11
0
 public void ToTag()
 {
     var service = new PushService
         {
             RequestBuilder = RequestBuilderHelper.Build()
         };
     var pushNotification = new PushNotificationRequest
         {
             Tags = new List<string> {"africa"},
             Payload = new PushPayload
                 {
                     Alert = "Alert 2"
                 }
         };
     var asyncTestHelper = new AsyncTestHelper();
     service.Execute(pushNotification, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
     asyncTestHelper.Wait();
 }
コード例 #12
0
 public void Simple()
 {
     var service = new PushService
         {
             RequestBuilder = RequestBuilderHelper.Build()
         };
     var pushNotification = new PushNotificationRequest
         {
             PushIds = new List<string> {RemoteSettings.AndroidPushId},
             Payload = new PushPayload
                 {
                     Alert = "Alert 2"
                 }
         };
     var asyncTestHelper = new AsyncTestHelper();
     service.Execute(pushNotification, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
     asyncTestHelper.Wait();
 }
コード例 #13
0
        public void Simple()
        {

            var service = new ModifyTagService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var tokens = new ModifyTagRequest
            {
                Tag = "myTag",
                AddDeviceTokens = new List<string> { RemoteSettings.AppleDeviceId },
            };
            
            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(tokens, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);

            asyncTestHelper.Wait();
        }
コード例 #14
0
        public void Tags()
        {
            var service = new AddRegistrationService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var registration = new AddRegistrationRequest
            {
                PushId = RemoteSettings.AndroidPushId,
                Tags   = new List <string> {
                    "bangladesh"
                }
            };

            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(registration, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #15
0
        public void Simple()
        {
            var service = new BroadcastService
                {
                    RequestBuilder = RequestBuilderHelper.Build()
                };

            var broadcastNotification = new BroadcastNotificationRequest
                {
                    Payload = new PushPayload
                        {
                            Alert = "Alert 2",
                            Badge = Badge.Increment()
                        }
                };

            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(broadcastNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #16
0
        public void Simple()
        {
            var service = new ModifyTagService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var tokens = new ModifyTagRequest
            {
                Tag             = "myTag",
                AddDeviceTokens = new List <string> {
                    RemoteSettings.AppleDeviceId
                },
            };

            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(tokens, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);

            asyncTestHelper.Wait();
        }
コード例 #17
0
        public void Simple()
        {
            var service = new BroadcastService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };

            var broadcastNotification = new BroadcastNotificationRequest
            {
                Payload = new PushPayload
                {
                    Alert = "Alert 2",
                    Badge = Badge.Increment()
                }
            };

            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(broadcastNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #18
0
        public void ToTag()
        {
            var service = new PushService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var pushNotification = new PushNotificationRequest
            {
                Tags = new List <string> {
                    "africa"
                },
                Payload = new PushPayload
                {
                    Alert = "Alert 2"
                }
            };
            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(pushNotification, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #19
0
        public void Simple()
        {
            var service = new PushService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var pushNotification = new PushNotificationRequest
            {
                PushIds = new List <string> {
                    RemoteSettings.AndroidPushId
                },
                Payload = new PushPayload
                {
                    Alert = "Alert 2"
                }
            };
            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(pushNotification, x => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #20
0
        public void ToAlias()
        {
            var service = new PushService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };

            var random = new Random();
            var pushNotification = new PushNotificationRequest
            {
                Aliases = new List<string>(new string[] { "1gzod" }),                
                Payload = new PushPayload
                {
                    Badge = random.Next(100),
                    Alert = "What's up iPhone",
                }
            };

            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(pushNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #21
0
        public void ToAlias()
        {
            var service = new PushService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };

            var random           = new Random();
            var pushNotification = new PushNotificationRequest
            {
                Aliases = new List <string>(new string[] { "1gzod" }),
                Payload = new PushPayload
                {
                    Badge = random.Next(100),
                    Alert = "What's up iPhone",
                }
            };

            var asyncTestHelper = new AsyncTestHelper();

            service.Execute(pushNotification, response => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
コード例 #22
0
    public void Simple()
    {
        var service = new PushService
        {
            RequestBuilder = RequestBuilderHelper.Build()
        };
        var request = new PushNotificationRequest
        {
            DeviceTokens = new List <string>
            {
                "BadToken"
            },
            Payload = new PushPayload
            {
                Alert = "Alert"
            },
        };

        Exception exception = null;

        try
        {
            var asyncTestHelper = new AsyncTestHelper();
            service.Execute(request, respone => asyncTestHelper.Callback(null), asyncTestHelper.HandleException);
            asyncTestHelper.Wait();
        }
        catch (Exception e)
        {
            exception = e;
        }

        var remoteException = exception as RemoteException;

        Assert.IsNotNull(remoteException);
        Assert.AreEqual("{\"error_code\": 40001, \"details\": {\"device_tokens.0.device_token\": [\"device_token contains an invalid device token: BADTOKEN\"]}, \"error\": \"Data validation error\"}", remoteException.Message);
    }