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(); }
public void TestSignUpASync() { Task.Run(async() => { var user = new NCMBUser(); user.Set("userName", "TestUser"); user.Set("password", "TestPass"); await user.SignUp(); Console.WriteLine(user.ObjectId()); Assert.AreNotEqual(user.ObjectId(), ""); await user.Delete(); NCMBUser.Logout(); }).GetAwaiter().GetResult(); }
public void TestLoginASync() { Task.Run(async() => { var user = new NCMBUser(); user.Set("userName", "TestLogin"); user.Set("password", "TestPass"); await user.SignUp(); user = new NCMBUser(); user.Set("userName", "TestLogin"); user.Set("password", "TestPass"); Assert.AreEqual(await user.Login(), true); Console.WriteLine(user.ObjectId()); Assert.AreNotEqual(user.ObjectId(), ""); Assert.AreNotEqual(_ncmb.SessionToken, ""); Assert.NotNull(_ncmb.SessionToken); await user.Delete(); NCMBUser.Logout(); }).GetAwaiter().GetResult(); }