Esempio n. 1
0
        public void TestGetIDAfterCreateFromURI()
        {
            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/dummyID"));

            Assert.IsNotNull(group.ID);
            Assert.AreEqual("dummyID", group.ID);
        }
Esempio n. 2
0
        public void Test_0300_Delete()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(204, "");

            bool      done             = false;
            KiiGroup  deletedGroup     = null;
            Exception deletedException = null;

            group.Delete((KiiGroup retGroup, Exception retExp) =>
            {
                done             = true;
                deletedGroup     = retGroup;
                deletedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNull(deletedException);
            Assert.IsNotNull(deletedGroup);

            Assert.IsNull(group.Uri);
        }
        public void Test_0023_Save_update_add_remove_server_error_partial()
        {
            this.LogIn();

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

            KiiUser user = KiiUser.CreateByUri(new Uri("kiicloud://users/user1234"));

            group.RemoveUser(user);

            user = KiiUser.CreateByUri(new Uri("kiicloud://users/user5678"));
            group.AddUser(user);

            // set Response
            client.RequestUrl.Clear();
            this.SetStandardSaveResponse(client);
            client.AddResponse(new CloudException(400, "{}"));

            try
            {
                group.Save();
            }
            catch (GroupOperationException e)
            {
                Assert.AreEqual(0, e.AddFailedUsers.Count);
                Assert.AreEqual(1, e.RemoveFailedUsers.Count);
            }
        }
Esempio n. 4
0
        public void Test_0012_Save_update_delete()
        {
            this.LogIn();

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

            KiiUser user = KiiUser.CreateByUri(new Uri("kiicloud://users/user1234"));

            group.RemoveUser(user);


            // set Response
            client.RequestUrl.Clear();
            this.SetStandardSaveResponse();

            bool      done           = false;
            KiiGroup  savedGroup     = null;
            Exception savedException = null;

            group.Save((KiiGroup retGroup, Exception retExp) =>
            {
                done           = true;
                savedGroup     = retGroup;
                savedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNull(savedException);
            Assert.IsNotNull(savedGroup);

            Assert.AreEqual(1, client.RequestUrl.Count);
            Assert.AreEqual("https://api.kii.com/api/apps/appId/groups/group1234/members/user1234", client.RequestUrl [0]);
        }
Esempio n. 5
0
        public void Test_0403_ChangeName_server_error()
        {
            this.LogIn();

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

            group.Name = "testGroup";

            // set Response
            client.AddResponse(new CloudException(400, "{ \"errorCode\" : \"INVALID_INPUT_DATA\", \"message\" : \"There are validation errors\", \"suppressed\" : [ ]}"));

            bool      done             = false;
            KiiGroup  changedGroup     = null;
            Exception changedException = null;

            group.ChangeName("newGroupName", (KiiGroup retGroup, Exception retExp) =>
            {
                done             = true;
                changedGroup     = retGroup;
                changedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(changedException);
            Assert.IsTrue(changedException is CloudException);
            Assert.IsNotNull(changedGroup);
            Assert.AreEqual("group1234", changedGroup.ID);
            Assert.AreEqual("testGroup", changedGroup.Name);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public void Test_0200_Refresh()
        {
            this.LogIn();

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

            // set Response
            this.SetStandardRefreshResponse();

            bool      done               = false;
            KiiGroup  refreshedGroup     = null;
            Exception refreshedException = null;

            group.Refresh((KiiGroup retGroup, Exception retExp) =>
            {
                done               = true;
                refreshedGroup     = retGroup;
                refreshedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNull(refreshedException);
            Assert.IsNotNull(refreshedGroup);

            Assert.AreEqual("testing group", group.Name);
            Assert.AreEqual("kiicloud://users/e3137ebe-2874-4d02-b7ef-6780bf8ecc1d", group.Owner.Uri.ToString());
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        public void Test_0203_Refresh_broken_no_groupId()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "{" +
                               "\"name\" : \"testing group\"," +
                               "\"owner\" : \"e3137ebe-2874-4d02-b7ef-6780bf8ecc1d\"}");

            bool      done               = false;
            KiiGroup  refreshedGroup     = null;
            Exception refreshedException = null;

            group.Refresh((KiiGroup retGroup, Exception retExp) =>
            {
                done               = true;
                refreshedGroup     = retGroup;
                refreshedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(refreshedException);
            Assert.IsTrue(refreshedException is IllegalKiiBaseObjectFormatException);
            Assert.IsNotNull(refreshedGroup);
            Assert.AreEqual("group1234", refreshedGroup.ID);
        }
Esempio n. 11
0
        public void Test_0202_Refresh_broken_json()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "broken");

            bool      done               = false;
            KiiGroup  refreshedGroup     = null;
            Exception refreshedException = null;

            group.Refresh((KiiGroup retGroup, Exception retExp) =>
            {
                done               = true;
                refreshedGroup     = retGroup;
                refreshedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(refreshedException);
            Assert.IsTrue(refreshedException is IllegalKiiBaseObjectFormatException);
            Assert.IsNotNull(refreshedGroup);
            Assert.AreEqual("group1234", refreshedGroup.ID);
        }
Esempio n. 12
0
        public void Test_0204_Refresh_broken_no_name()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "{" +
                               "\"groupID\" : \"90def9aa-565e-4037-bde8-3a8704c7d806\"," +
                               "\"owner\" : \"e3137ebe-2874-4d02-b7ef-6780bf8ecc1d\"}");

            bool      done               = false;
            KiiGroup  refreshedGroup     = null;
            Exception refreshedException = null;

            group.Refresh((KiiGroup retGroup, Exception retExp) =>
            {
                done               = true;
                refreshedGroup     = retGroup;
                refreshedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(refreshedException);
            Assert.IsTrue(refreshedException is IllegalKiiBaseObjectFormatException);
            Assert.IsNotNull(refreshedGroup);
            // We won't rollback the id change after the exception happens.
            Assert.AreEqual("90def9aa-565e-4037-bde8-3a8704c7d806", refreshedGroup.ID);
        }
Esempio n. 13
0
        public void Test_0205_Refresh_broken_no_owner()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "{" +
                               "\"groupID\" : \"90def9aa-565e-4037-bde8-3a8704c7d806\"," +
                               "\"name\" : \"testing group\"}");

            bool      done               = false;
            KiiGroup  refreshedGroup     = null;
            Exception refreshedException = null;

            group.Refresh((KiiGroup retGroup, Exception retExp) =>
            {
                done               = true;
                refreshedGroup     = retGroup;
                refreshedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNull(refreshedException);
            Assert.IsNotNull(refreshedGroup);

            Assert.AreEqual("testing group", refreshedGroup.Name);
            Assert.AreEqual("90def9aa-565e-4037-bde8-3a8704c7d806", refreshedGroup.ID);
            Assert.IsNull(refreshedGroup.Owner);
        }
Esempio n. 14
0
        public void Test_0206_Refresh_server_error()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(new CloudException(400, "{ \"errorCode\" : \"INVALID_INPUT_DATA\", \"message\" : \"There are validation errors\", \"suppressed\" : [ ]}"));

            bool      done               = false;
            KiiGroup  refreshedGroup     = null;
            Exception refreshedException = null;

            group.Refresh((KiiGroup retGroup, Exception retExp) =>
            {
                done               = true;
                refreshedGroup     = retGroup;
                refreshedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(refreshedException);
            Assert.IsTrue(refreshedException is CloudException);
            Assert.IsNotNull(refreshedGroup);
            Assert.AreEqual("group1234", refreshedGroup.ID);
        }
Esempio n. 15
0
        public void Test_0401_ChangeName_null()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(204, "");

            bool      done             = false;
            KiiGroup  changedGroup     = null;
            Exception changedException = null;

            group.ChangeName(null, (KiiGroup retGroup, Exception retExp) =>
            {
                done             = true;
                changedGroup     = retGroup;
                changedException = retExp;
            });

            Assert.IsTrue(done);
            Assert.IsNotNull(changedException);
            Assert.IsTrue(changedException is ArgumentException);
            Assert.IsNotNull(changedGroup);
            Assert.AreEqual("group1234", changedGroup.ID);
        }
Esempio n. 16
0
        public void Test_0000_CreateByUri()
        {
            KiiGroup group = KiiGroup.CreateByUri(new Uri("kiicloud://groups/abcd"));

            Assert.IsNotNull(group);
            Assert.AreEqual(null, group.Name);
        }
        public void Test_0304_Uri_GroupScope_endWith_shash()
        {
            Kii.Initialize("abbId", "appKey", Kii.Site.JP);

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

            Assert.AreEqual("kiicloud://groups/group1234/buckets/name1234", bucket.Uri.ToString());
        }
        public void Test_0202_Refresh_broken_json()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "broken");
            group.Refresh();
        }
        public void Test_0302_Delete_server_error()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(new CloudException(400, "{}"));
            group.Delete();
        }
        public void Test_0401_ChangeName_null()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(204, "");
            group.ChangeName(null);
        }
        public void Test_0403_ChangeName_server_error()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(new CloudException(400, "{}"));
            group.ChangeName("newGroupName");
        }
        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);
        }
        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_0300_Delete()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(204, "");
            group.Delete();

            Assert.IsNull(group.Uri);
        }
        public void Test_0400_ChangeName()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(204, "");
            group.ChangeName("newName");

            Assert.AreEqual("newName", group.Name);
        }
        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_0200_Refresh()
        {
            this.LogIn();

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

            // set Response
            this.SetStandardRefreshResponse(client);
            group.Refresh();

            Assert.AreEqual("testing group", group.Name);
            Assert.AreEqual("kiicloud://users/e3137ebe-2874-4d02-b7ef-6780bf8ecc1d", group.Owner.Uri.ToString());
        }
        public void Test_0203_Refresh_broken_no_groupId()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "{" +
                               "\"name\" : \"testing group\"," +
                               "\"owner\" : \"e3137ebe-2874-4d02-b7ef-6780bf8ecc1d\"}");

            group.Refresh();
        }
        public void Test_0204_Refresh_broken_no_name()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "{" +
                               "\"groupID\" : \"90def9aa-565e-4037-bde8-3a8704c7d806\"," +
                               "\"owner\" : \"e3137ebe-2874-4d02-b7ef-6780bf8ecc1d\"}");

            group.Refresh();
        }
        public void Test_0205_Refresh_broken_no_owner()
        {
            this.LogIn();

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

            // set Response
            client.AddResponse(200, "{" +
                               "\"groupID\" : \"90def9aa-565e-4037-bde8-3a8704c7d806\"," +
                               "\"name\" : \"testing group\"}");
            group.Refresh();

            Assert.AreEqual("testing group", group.Name);
            Assert.AreEqual("90def9aa-565e-4037-bde8-3a8704c7d806", group.ID);
            Assert.IsNull(group.Owner);
        }