public void RegisterGroupWithIDWithInvalidIDSyncTest() { string groupID = "aaa-bbb-@"; string groupName = "group-" + DateTime.Now.Ticks.ToString(); KiiGroup.RegisterGroupWithID(groupID, groupName, null); }
public void RegisterGroupWithIDWithoutMembersSyncTest() { string groupID = GetGroupID(); string groupName = "group-" + DateTime.Now.Ticks.ToString(); client.AddResponse(200, "{\"groupID\":\"" + groupID + "\"}"); KiiGroup group = KiiGroup.RegisterGroupWithID(groupID, groupName, null); Assert.AreEqual(groupID, group.ID); Assert.AreEqual(groupName, group.Name); Assert.AreEqual(KiiUser.CurrentUser.ID, group.Owner.ID); JsonObject expectedRequestBody = new JsonObject(); JsonArray expectedMembers = new JsonArray(); expectedMembers.Put("user-member-0001"); expectedMembers.Put("user-member-0002"); expectedRequestBody.Put("owner", KiiUser.CurrentUser.ID); expectedRequestBody.Put("name", groupName); Assert.AreEqual(KiiHttpMethod.PUT, client.RequestMethod [0]); Assert.AreEqual("https://api.kii.com/api/apps/" + AppID + "/groups/" + groupID, client.RequestUrl [0]); KiiAssertion.AssertJson(expectedRequestBody, new JsonObject(client.RequestBody [0])); Assert.AreEqual("application/vnd.kii.GroupCreationRequest+json", client.RequestHeader[0]["content-type"]); }
public void Test() { string groupID = GetGroupID(); string groupName = "group-" + DateTime.Now.Ticks.ToString(); IList <KiiUser> members = new List <KiiUser>(); members.Add(this.member1); members.Add(this.member2); CountDownLatch cd = new CountDownLatch(1); KiiGroup group = null; Exception exception = null; KiiGroup.RegisterGroupWithID(groupID, groupName, members, (KiiGroup result, Exception e) => { group = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(exception); Assert.AreEqual(groupID, group.ID); Assert.AreEqual(groupName, group.Name); Assert.AreEqual(KiiUser.CurrentUser.ID, group.Owner.ID); members = group.ListMembers(); Assert.AreEqual(3, members.Count); // 2 members and owner }
public void RegisterGroupWithIDWhenNotLoggedinSyncTest() { KiiUser.LogOut(); string groupID = GetGroupID(); string groupName = "group-" + DateTime.Now.Ticks.ToString(); KiiGroup.RegisterGroupWithID(groupID, groupName, null); }
public void RegisterGroupWithIDConfrictSyncTest() { string groupID = GetGroupID(); string groupName = "group-" + DateTime.Now.Ticks.ToString(); client.AddResponse(new ConflictException("", null, "", ConflictException.Reason.GROUP_ALREADY_EXISTS)); KiiGroup.RegisterGroupWithID(groupID, groupName, null); }
public void RegisterGroupWithIDASyncTest() { string groupID = GetGroupID(); string groupName = "group-" + DateTime.Now.Ticks.ToString(); List <KiiUser> members = new List <KiiUser>(); members.Add(KiiUser.CreateByUri(new Uri("kiicloud://users/user-member-0001"))); members.Add(KiiUser.CreateByUri(new Uri("kiicloud://users/user-member-0002"))); client.AddResponse(200, "{\"groupID\":\"" + groupID + "\"}"); CountDownLatch cd = new CountDownLatch(1); KiiGroup group = null; Exception exception = null; KiiGroup.RegisterGroupWithID(groupID, groupName, members, (KiiGroup result, Exception e) => { group = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(exception); Assert.AreEqual(groupID, group.ID); Assert.AreEqual(groupName, group.Name); Assert.AreEqual(KiiUser.CurrentUser.ID, group.Owner.ID); JsonObject expectedRequestBody = new JsonObject(); JsonArray expectedMembers = new JsonArray(); expectedMembers.Put("user-member-0001"); expectedMembers.Put("user-member-0002"); expectedRequestBody.Put("owner", KiiUser.CurrentUser.ID); expectedRequestBody.Put("name", groupName); expectedRequestBody.Put("members", expectedMembers); Assert.AreEqual(KiiHttpMethod.PUT, client.RequestMethod [0]); Assert.AreEqual("https://api.kii.com/api/apps/" + AppID + "/groups/" + groupID, client.RequestUrl [0]); KiiAssertion.AssertJson(expectedRequestBody, new JsonObject(client.RequestBody [0])); Assert.AreEqual("application/vnd.kii.GroupCreationRequest+json", client.RequestHeader[0]["content-type"]); }
public void RegisterGroupWithIDWithoutGroupNameASyncTest() { string groupID = GetGroupID(); CountDownLatch cd = new CountDownLatch(1); KiiGroup group = null; Exception exception = null; KiiGroup.RegisterGroupWithID(groupID, null, null, (KiiGroup result, Exception e) => { group = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(group); Assert.IsNotNull(exception); Assert.IsInstanceOfType(typeof(ArgumentException), exception); }
public void RegisterGroupWithIDWithInvalidIDASyncTest() { string groupID = "aaa-bbb-$"; string groupName = "group-" + DateTime.Now.Ticks.ToString(); CountDownLatch cd = new CountDownLatch(1); KiiGroup group = null; Exception exception = null; KiiGroup.RegisterGroupWithID(groupID, groupName, null, (KiiGroup result, Exception e) => { group = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(group); Assert.IsNotNull(exception); Assert.IsInstanceOfType(typeof(ArgumentException), exception); }
public void RegisterGroupWithIDConfrictASyncTest() { string groupID = GetGroupID(); string groupName = "group-" + DateTime.Now.Ticks.ToString(); client.AddResponse(new ConflictException("", null, "", ConflictException.Reason.GROUP_ALREADY_EXISTS)); CountDownLatch cd = new CountDownLatch(1); KiiGroup group = null; Exception exception = null; KiiGroup.RegisterGroupWithID(groupID, groupName, null, (KiiGroup result, Exception e) => { group = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(group); Assert.IsNotNull(exception); Assert.IsInstanceOfType(typeof(GroupOperationException), exception); }
public void RegisterGroupWithIDWithoutGroupNameSyncTest() { string groupID = GetGroupID(); KiiGroup.RegisterGroupWithID(groupID, null, null); }
public void RegisterGroupWithIDWithoutGroupIDSyncTest() { string groupName = "group-" + DateTime.Now.Ticks.ToString(); KiiGroup.RegisterGroupWithID(null, groupName, null); }