public void Test_0001_Parse_GCM_PushToApp()
        {
            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("\"bucketID\" : \"BUCKET-000001-AAAAAA\",");
            json.AppendLine("\"objectID\" : \"OBJECT-000001-AAAAAA\",");
            json.AppendLine("\"bucketType\" : \"SYNC\"");
            json.AppendLine("}");

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

            Assert.AreEqual("abc", message.GetString("string-property"));
            Assert.AreEqual(10, message.GetInt("int-property"));
            Assert.AreEqual(true, message.GetBoolean("bool-property"));
            Assert.AreEqual(10.5, message.GetDouble("double-property"));
            Assert.AreEqual(ReceivedMessage.MessageType.PUSH_TO_APP, message.PushMessageType);
            Assert.AreEqual("kiicloud://users/USER-000001-AAAAAA", message.Sender.Uri.ToString());
            Assert.AreEqual(ReceivedMessage.Scope.APP, message.ObjectScope);
            Assert.AreEqual("kiicloud://groups/GROUP-000001-AAAAAA", message.ObjectScopeGroup.Uri.ToString());
            Assert.AreEqual("kiicloud://users/USER-000001-BBBBBB", message.ObjectScopeUser.Uri.ToString());
            Assert.AreEqual("kiicloud://buckets/BUCKET-000001-AAAAAA", message.KiiBucket.Uri.ToString());
            Assert.AreEqual("kiicloud://buckets/BUCKET-000001-AAAAAA/objects/OBJECT-000001-AAAAAA", message.KiiObject.Uri.ToString());
        }
        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);
        }
예제 #4
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());
            }
        }
예제 #5
0
        public void TestParseSender()
        {
            List <string> errors = new List <string>();

            for (int i = 0; i < SENDER_TEST_CASES.Length; i++)
            {
                TestCase         tc      = SENDER_TEST_CASES[i];
                PushToAppMessage message = (PushToAppMessage)ReceivedMessage.Parse(tc.GetPushMessage());
                ExpectResult     result  = tc.result;
                try
                {
                    if (result.Value == null)
                    {
                        Assert.IsNull(message.Sender);
                    }
                    else
                    {
                        Assert.IsNotNull(message.Sender);
                        Assert.AreEqual(result.Value, message.Sender.Uri.ToString());
                    }
                }
                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());
            }
        }