Пример #1
0
        public void Test_0105_ListMembers_empty_userId()
        {
            this.LogIn();

            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/group1234"));

            // Set Response of empty user ID to throw exception from ListMembers request
            client.AddResponse(200, "{\"members\":[" +
                               "{\"userID\":\"\"}" +
                               "]}");

            bool            done          = false;
            IList <KiiUser> listMembers   = null;
            Exception       listException = null;

            group.ListMembers((IList <KiiUser> retUserList, Exception retExp) =>
            {
                done          = true;
                listMembers   = retUserList;
                listException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(listException);
            Assert.IsTrue(listException is IllegalKiiBaseObjectFormatException);
            Assert.IsNull(listMembers);
        }
Пример #2
0
        public void Test_0101_ListMembers_NoID()
        {
            this.LogIn();

            KiiGroup group = Kii.Group("newGroup");

            // set Response
            this.SetStandardListResponse();

            bool            done          = false;
            IList <KiiUser> listMembers   = null;
            Exception       listException = null;

            group.ListMembers((IList <KiiUser> retUserList, Exception retExp) =>
            {
                done          = true;
                listMembers   = retUserList;
                listException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(listException);
            Assert.IsTrue(listException is InvalidOperationException);
            Assert.IsNull(listMembers);
        }
Пример #3
0
        public void Test_0103_ListMembers_empty_member()
        {
            this.LogIn();

            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/group1234"));

            // Set Response of no entry to throw exception from ListMembers request
            client.AddResponse(200, "{\"members\":[]}");

            bool            done          = false;
            IList <KiiUser> listMembers   = null;
            Exception       listException = null;

            group.ListMembers((IList <KiiUser> retUserList, Exception retExp) =>
            {
                done          = true;
                listMembers   = retUserList;
                listException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNull(listException);
            Assert.IsNotNull(listMembers);

            Assert.AreEqual(0, listMembers.Count);
        }
Пример #4
0
        public void Test_1_2_GroupWithID_ExistsInCloud_ListMembers()
        {
            // mock list members response.
            MockHttpClientFactory factory = new MockHttpClientFactory();

            Kii.HttpClientFactory = factory;
            MockHttpClient client = (MockHttpClient)factory.Client;

            client.AddResponse(200, "{" +
                               "\"members\":[{" +
                               "\"userID\" : \"dummyUser\"" +
                               "}]" +
                               "}");

            // create group
            string   groupId = "dummyId";
            KiiGroup group   = KiiGroup.GroupWithID(groupId);

            // list members
            IList <KiiUser> members = group.ListMembers();

            Assert.AreEqual(1, members.Count);

            //check request
            string url = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "groups", "dummyId", "members");

            Assert.AreEqual(url, client.RequestUrl[0]);
            Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod[0]);
            MockHttpHeaderList headerList = client.RequestHeader[0];

            Assert.AreEqual("appId", headerList["X-Kii-AppID"]);
            Assert.AreEqual("appKey", headerList["X-Kii-AppKey"]);
            Assert.AreEqual("Bearer token1234", client.RequestHeader[0]["Authorization"]);
            Assert.IsTrue(headerList["X-Kii-SDK"].StartsWith("sn=cs;sv="));
        }
Пример #5
0
        public void Test_0100_ListMembers()
        {
            this.LogIn();

            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/group1234"));

            // set Response
            this.SetStandardListResponse();

            bool            done          = false;
            IList <KiiUser> listMembers   = null;
            Exception       listException = null;

            group.ListMembers((IList <KiiUser> retUserList, Exception retExp) =>
            {
                done          = true;
                listMembers   = retUserList;
                listException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNull(listException);
            Assert.IsNotNull(listMembers);

            Assert.AreEqual(4, listMembers.Count);
        }
Пример #6
0
        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 Test_0101_ListMembers_NoID()
        {
            this.LogIn();

            KiiGroup group = Kii.Group("newGroup");

            // set Response
            this.SetStandardListResponse(client);
            group.ListMembers();
        }
        public void Test_0105_ListMembers_empty_userId()
        {
            this.LogIn();

            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/group1234"));

            // set Response
            client.AddResponse(200, "{\"members\":[" +
                               "{\"userID\":\"\"}" +
                               "]}");
            group.ListMembers();
        }
        public void Test_0103_ListMembers_empty_member()
        {
            this.LogIn();

            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/group1234"));

            // set Response
            client.AddResponse(200, "{\"members\":[]}");
            IList <KiiUser> members = group.ListMembers();

            Assert.AreEqual(0, members.Count);
        }
        public void Test_0100_ListMembers()
        {
            this.LogIn();

            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/group1234"));

            // set Response
            this.SetStandardListResponse(client);
            IList <KiiUser> members = group.ListMembers();

            Assert.AreEqual(4, members.Count);
        }