public void Test_0012_Parse_APNS_PushToApp_Without_sender()
        {
            LogIn();
            StringBuilder json = new StringBuilder();

            json.AppendLine("{");
            json.AppendLine("\"aps\" : {},");
            json.AppendLine("\"string-property\" : \"abc\",");
            json.AppendLine("\"int-property\" : 10,");
            json.AppendLine("\"bool-property\" : true,");
            json.AppendLine("\"double-property\" : 10.5,");
            json.AppendLine("\"st\" : \"APP\",");
            json.AppendLine("\"sg\" : \"GROUP-000001-AAAAAA\",");
            json.AppendLine("\"su\" : \"USER-000001-BBBBBB\",");
            json.AppendLine("\"bi\" : \"BUCKET-000001-AAAAAA\",");
            json.AppendLine("\"oi\" : \"OBJECT-000001-AAAAAA\",");
            json.AppendLine("\"bt\" : \"SYNC\"");
            json.AppendLine("}");

            PushToAppMessage msg = (PushToAppMessage)ReceivedMessage.Parse(json.ToString());

            Assert.IsTrue(msg.ContainsKiiBucket());
            Assert.IsTrue(msg.ContainsKiiObject());
            Assert.AreEqual("kiicloud://buckets/BUCKET-000001-AAAAAA/objects/OBJECT-000001-AAAAAA", msg.KiiObject.Uri.ToString());
            Assert.AreEqual("BUCKET-000001-AAAAAA", msg.KiiBucket.Name);
            Assert.AreEqual("kiicloud://groups/GROUP-000001-AAAAAA", msg.ObjectScopeGroup.Uri.ToString());
            Assert.AreEqual("kiicloud://users/USER-000001-BBBBBB", msg.ObjectScopeUser.Uri.ToString());
            Assert.AreEqual(ReceivedMessage.MessageType.PUSH_TO_APP, msg.PushMessageType);
        }
        public void Test_0008_Parse_GCM_PushToApp_Without_bucketID()
        {
            LogIn();
            StringBuilder json = new StringBuilder();

            json.AppendLine("{");
            json.AppendLine("\"string-property\" : \"abc\",");
            json.AppendLine("\"int-property\" : 10,");
            json.AppendLine("\"bool-property\" : true,");
            json.AppendLine("\"double-property\" : 10.5,");
            json.AppendLine("\"origin\" : \"EVENT\",");
            json.AppendLine("\"sender\" : \"USER-000001-AAAAAA\",");
            json.AppendLine("\"objectScopeType\" : \"APP\",");
            json.AppendLine("\"objectScopeGroupID\" : \"GROUP-000001-AAAAAA\",");
            json.AppendLine("\"objectScopeUserID\" : \"USER-000001-BBBBBB\",");
            json.AppendLine("\"objectID\" : \"OBJECT-000001-AAAAAA\",");
            json.AppendLine("\"bucketType\" : \"SYNC\"");
            json.AppendLine("}");

            PushToAppMessage msg = (PushToAppMessage)ReceivedMessage.Parse(json.ToString());

            Assert.IsFalse(msg.ContainsKiiBucket());
            Assert.IsFalse(msg.ContainsKiiObject());
            Assert.IsNull(msg.KiiObject);
            Assert.IsNull(msg.KiiBucket);
            Assert.AreEqual("kiicloud://groups/GROUP-000001-AAAAAA", msg.ObjectScopeGroup.Uri.ToString());
            Assert.AreEqual("kiicloud://users/USER-000001-BBBBBB", msg.ObjectScopeUser.Uri.ToString());
            Assert.AreEqual(ReceivedMessage.MessageType.PUSH_TO_APP, msg.PushMessageType);
        }
예제 #3
0
        public void TestParseKiiObject()
        {
            List <string> errors = new List <string>();

            for (int i = 0; i < OBJECT_TEST_CASES.Length; i++)
            {
                TestCase         tc      = OBJECT_TEST_CASES[i];
                PushToAppMessage message = (PushToAppMessage)ReceivedMessage.Parse(tc.GetPushMessage());
                ExpectResult     result  = tc.result;
                Console.WriteLine("No: " + (i + 1) + " message: " + tc.GetPushMessage());
                try
                {
                    Assert.IsNotNull(message);
                    if (result.Value == null)
                    {
                        Assert.IsFalse(message.ContainsKiiObject());
                        Assert.IsNull(message.KiiObject);
                    }
                    else
                    {
                        Assert.IsNotNull(message.KiiObject);
                        Assert.AreEqual(result.Value, message.KiiObject.Uri.ToString());
                        Assert.IsTrue(message.ContainsKiiObject());
                    }
                }
                catch (AssertionException e)
                {
                    errors.Add("TestCase: " + (i + 1) + " message:" + e.Message);
                }
            }
            if (errors.Count > 0)
            {
                StringBuilder sb = new StringBuilder("One or More testcase failed. \n");
                foreach (string error in errors)
                {
                    sb.Append(error);
                }
                Assert.Fail(sb.ToString());
            }
        }