예제 #1
0
        public void Test_0006_BuildWithNullGCMMessage()
        {
            GCMData data = new GCMData();

            data.Put("payload", "abc");
            KiiPushMessage.BuildWith(data).WithGCMMessage(null);
        }
예제 #2
0
 /// <summary>
 /// Build and return GCMMessage.
 /// </summary>
 /// <remarks></remarks>
 /// <returns>GCMMessage</returns>
 public GCMMessage Build()
 {
     if (this.mMessageData != null && !GCMData.IsValidData(this.mMessageData))
     {
         throw new SystemException("Data contains key that is GCM reserve word");
     }
     return(new GCMMessage(this.mMessageData, this.mParent));
 }
        public void Test_0012_GCMData_ValidKey_end_with_google()
        {
            GCMData data = new GCMData();

            data.Put("xxx_google", "abc");
            JsonObject json = data.ToJsonObject();

            Assert.AreEqual(json.Get("xxx_google"), "abc");
        }
예제 #4
0
 /// <summary>
 /// Create a builder with the data that will be sent only to android-GCM devices.
 /// Corresponding to GCM's "data"
 /// The data specified here will be merged with the data specified on <see cref="KiiPushMessage.BuildWith(KiiPushMessage.Data)"/>
 /// </summary>
 /// <remarks></remarks>
 /// <param name="data">Data.</param>
 /// <returns>Builder of the message.</returns>
 /// <exception cref='ArgumentNullException'>
 /// Is thrown when an argument is null.
 /// </exception>
 public Builder WithGCMData(GCMData data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data must not be null");
     }
     this.mMessageData = data;
     return(this);
 }
            /// <summary>
            /// Build and return KiiPushMessage.
            /// </summary>
            /// <remarks></remarks>
            /// <returns>KiiPushMessage</returns>
            public KiiPushMessage Build()
            {
                if (this.mGcm.OptBoolean("enabled"))
                {
                    if (this.mMessageData != null && !GCMData.IsValidData(this.mMessageData))
                    {
                        throw new SystemException("Data contains key that is GCM reserve word");
                    }
                }
                KiiPushMessage msg = new KiiPushMessage(this.mMessageData, this.mParent, this.mGcm, this.mApns, this.mMqtt);

                return(msg);
            }
예제 #6
0
        public void Test_0005_GCMMessage()
        {
            GCMData data = new GCMData();

            data.Put("payload", "abc");
            GCMMessage apns = GCMMessage.CreateBuilder()
                              .WithGCMData(data)
                              .WithCollapseKey("CollapseKey")
                              .WithDelayWhileIdle(true)
                              .WithRestrictedPackageName("RestrictedPackageName")
                              .WithTimeToLive(4)
                              .Build();
            JsonObject json = apns.ToJson();

            Assert.AreEqual(true, json.Get("enabled"));
            Assert.AreEqual("CollapseKey", json.Get("collapseKey"));
            Assert.AreEqual(true, json.Get("delayWhileIdle"));
            Assert.AreEqual(4, json.Get("timeToLive"));
            Assert.AreEqual("RestrictedPackageName", json.Get("restrictedPackageName"));
            Assert.AreEqual("abc", json.GetJsonObject("data").Get("payload"));
        }
        public void Test_0006_GCMData_InvalidKey_data()
        {
            GCMData data = new GCMData();

            data.Put("data", "abc");
        }
        public void Test_0005_GCMData_InvalidKey_collapse_key()
        {
            GCMData data = new GCMData();

            data.Put("collapse_key", "abc");
        }
        public void Test_0004_GCMData_InvalidKey_registration_ids()
        {
            GCMData data = new GCMData();

            data.Put("registration_ids", "abc");
        }
        public void Test_0003_GCMData_InvalidKey_from()
        {
            GCMData data = new GCMData();

            data.Put("from", "abc");
        }
        public void Test_0011_GCMData_InvalidKey_start_with_google()
        {
            GCMData data = new GCMData();

            data.Put("google_xxx", "abc");
        }
        public void Test_0010_GCMData_InvalidKey_dry_run()
        {
            GCMData data = new GCMData();

            data.Put("dry_run", "abc");
        }
        public void Test_0009_GCMData_InvalidKey_restricted_package_name()
        {
            GCMData data = new GCMData();

            data.Put("restricted_package_name", "abc");
        }
        public void Test_0008_GCMData_InvalidKey_time_to_live()
        {
            GCMData data = new GCMData();

            data.Put("time_to_live", "abc");
        }
        public void Test_0007_GCMData_InvalidKey_delay_while_idle()
        {
            GCMData data = new GCMData();

            data.Put("delay_while_idle", "abc");
        }