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); }
public void TestParseKiiBucket() { List <string> errors = new List <string>(); for (int i = 0; i < BUCKET_TEST_CASES.Length; i++) { TestCase tc = BUCKET_TEST_CASES[i]; PushToAppMessage message = (PushToAppMessage)ReceivedMessage.Parse(tc.GetPushMessage()); ExpectResult result = tc.result; try { Assert.IsNotNull(message); if (result.Value == null) { Assert.IsNull(message.KiiBucket); Assert.IsFalse(message.ContainsKiiBucket()); } else { Assert.IsNotNull(message.KiiBucket); Assert.AreEqual(result.Value, message.KiiBucket.Uri.ToString()); Assert.IsTrue(message.ContainsKiiBucket()); } } 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()); } }