예제 #1
0
        public void TestAddAndRemoveRole()
        {
            Task.Run(async() =>
            {
                var role1 = new NCMBRole();
                role1.Set("roleName", "role3");
                await role1.Save();
                Assert.NotNull(role1.Get("objectId"));

                var role2 = new NCMBRole();
                role2.Set("roleName", "role4");
                await role2.Save();
                Assert.NotNull(role2.Get("objectId"));

                var role3 = new NCMBRole();
                role3.Set("roleName", "role6");
                await role3.Save();
                Assert.NotNull(role3.Get("objectId"));

                await role1.AddRole(role2).AddRole(role3).Save();

                await role1.Fetch();

                var roles = await role1.FetchRole();

                Assert.AreEqual(roles.Length, 2);

                // Assert.AreEqual(role3.Get("roleName").ToString(), roles[0].Get("roleName").ToString());

                role1.ClearOperation();
                await role1.RemoveRole(role2).Save();
                await role1.Fetch();

                var roles2 = await role1.FetchRole();
                Assert.AreEqual(roles2.Length, 1);

                await role1.Delete();
                await role2.Delete();
                await role3.Delete();
            }).GetAwaiter().GetResult();
        }