//construct
 public PushPayload()
 {
     platform = null;
     audience = null;
     notification = null;
     message = null;
     options = new Options();
     jSetting = new JsonSerializerSettings();
     jSetting.NullValueHandling = NullValueHandling.Ignore;
     jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
 }
Beispiel #2
0
        public PushPayload(Platform platform, Audience audience, Message message , Options options = null)
        {
            Debug.Assert(platform != null);
            Debug.Assert(audience != null);
            Debug.Assert(message != null);

            this.platform = platform;
            this.audience = audience;
            this.message = message;
            this.options = options;

            jSetting = new JsonSerializerSettings();
            jSetting.NullValueHandling = NullValueHandling.Ignore;
            jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
        }
        public void testSendno() 
        {

            var json = new JObject();
            json.Add("sendno",JToken.FromObject(111));
            json.Add("apns_production", JToken.FromObject(false));

            Options options = new Options();
            options.sendno = 111;
            var jSetting = new JsonSerializerSettings();
            jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
            var jsonString = JsonConvert.SerializeObject(options, jSetting);
            var jsonObject = json.ToString(Formatting.None); 
            Assert.AreEqual(jsonObject, jsonString);
       }
        public PushPayload(Platform platform, Audience audience, Notification notification, Message message = null, SmsMessage sms_message = null, Options options = null)
        {
            Debug.Assert(platform != null);
            Debug.Assert(audience != null);
            Debug.Assert(notification != null || message != null);

            this.platform = platform;
            this.audience = audience;
            this.notification = notification;
            this.message = message;
            this.sms_message = sms_message;
            this.options = options;

            jSetting = new JsonSerializerSettings();
            jSetting.NullValueHandling = NullValueHandling.Ignore;
            jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
        }
 public void ResetOptionsTimeToLive(long timeToLive)
 {
     if (this.options == null)
     {
         this.options = new Options();
     }
     this.options.time_to_live = timeToLive;
 }
 public void ResetOptionsApnsProduction(bool apnsProduction)
 {
     if (this.options == null)
     {
         this.options = new Options();
     }
     this.options.apns_production = apnsProduction;
 }
 public void testIllegalTimeToLive()
 {
     Options options = new Options();
     options.time_to_live = -2;
 }
 public void testIllegalOverrideMsgId()
 {
     Options options = new Options();
     options.override_msg_id = -1;
 }
        public void testBigPushDuration() 
      {
             int sendno = ServiceHelper.generateSendno();
             JObject json = new JObject();
             json.Add("sendno", JToken.FromObject(sendno));
             json.Add("big_push_duration", JToken.FromObject(10));
             json.Add("apns_production", JToken.FromObject(false));
       
             Options options = new Options();
             options.sendno = sendno;
             options.big_push_duration=10;

             var jSetting = new JsonSerializerSettings();
             jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
             var jsonString = JsonConvert.SerializeObject(options, jSetting);
             var jsonObject = json.ToString(Formatting.None);

             Assert.AreEqual(jsonString, jsonObject);

    }
        public void testIllegalSendno()
        {

            Options options = new Options();
            options.sendno = -1;
        }
        public void testApnsProduction_True()
        {
            int sendno = ServiceHelper.generateSendno();

            JObject json = new JObject();
            json.Add("sendno", JToken.FromObject(sendno));
            json.Add("apns_production", JToken.FromObject(true));
         
        
            Options options = new Options();
            options.sendno = sendno;
            options.apns_production=true;

            var jSetting = new JsonSerializerSettings();
            jSetting.DefaultValueHandling = DefaultValueHandling.Ignore;
            var jsonString = JsonConvert.SerializeObject(options, jSetting);
            var jsonObject = json.ToString(Formatting.None);

            Assert.AreEqual(jsonObject, jsonString);
     }