Esempio n. 1
0
        public void TestAddUser()
        {
            Task.Run(async() =>
            {
                var acl = new NCMBAcl();
                acl.SetPublicWriteAccess(true);

                var user1    = new NCMBUser();
                var userName = "******";
                var password = "******";
                user1.Set("userName", userName);
                user1.Set("password", password);
                await user1.SignUp();
                var user = await NCMBUser.Login(userName, password);
                user.SetAcl(acl);
                await user.Save();

                var user2 = new NCMBUser();
                userName  = "******";
                password  = "******";
                user2.Set("userName", userName);
                user2.Set("password", password);
                await user2.SignUp();

                user = await NCMBUser.Login(userName, password);
                user.SetAcl(acl);
                await user.Save();

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


                await role1.AddUser(user1).AddUser(user2).Save();

                await role1.Fetch();

                var users = await role1.FetchUser();
                // Console.WriteLine(users.Length);
                Assert.AreEqual(2, users.Length);
                role1.ClearOperation();
                await role1.RemoveUser(user1).Save();
                users = await role1.FetchUser();
                Assert.AreEqual(1, users.Length);
                // Assert.AreEqual(user1.Get("userName").ToString(), users[0].Get("userName").ToString());
                await role1.Delete();
                await user1.Delete();
                await user2.Delete();
            }).GetAwaiter().GetResult();
        }
Esempio n. 2
0
 public void TestUploadWithAcl()
 {
     Task.Run(async() =>
     {
         var str  = "1,2,3";
         var data = System.Text.Encoding.ASCII.GetBytes(str);
         var file = new NCMBFile("test2.csv", data, "text/csv");
         var acl  = new NCMBAcl();
         acl.SetPublicReadAccess(true);
         acl.SetPublicWriteAccess(true);
         file.SetAcl(acl);
         await file.Save();
         Assert.NotNull(file.Get("fileName"));
     }).GetAwaiter().GetResult();
 }
Esempio n. 3
0
 public void TestSaveAndDeleteWithAclSync()
 {
     Task.Run(async() =>
     {
         var message = "Hello, world";
         var item    = new NCMBObject("DataStoreTest");
         item.Set("message", message);
         var acl = new NCMBAcl();
         acl.SetPublicReadAccess(true);
         acl.SetPublicWriteAccess(false);
         acl.SetRoleReadAccess("admin", true);
         acl.SetRoleWriteAccess("admin", true);
         item.SetAcl(acl);
         await item.Save();
         Assert.NotNull(item.Get("objectId"));
         Assert.AreEqual(item.Get("message").ToString(), message);
     }).GetAwaiter().GetResult();
 }