Exemplo n.º 1
0
    public IEnumerator Login(System.Action <string> cd)
    {
        WWWForm form = new WWWForm();

        form.AddField("login", log.text);
        form.AddField("password", pass.text);

        WWW www = new WWW("http://localhost:8080/users/logIn", form);

        yield return(www);

        if (www.error != null)
        {
            Debug.Log("Сервер ответил нет такого пользователя " + www.error);
            Debug.Log(www.error);
            message.text = "Неверный логин или пароль";
            yield break;
        }

        Debug.Log("Пользователь авторизован " + www.text);
        Repos r = new Repos();

        r.Save(www.text);
        //проверки
        Debug.Log("ПРОверка " + r.R);
        token = r.R;
        Debug.Log("Прроверка 2 " + token);
        cd(token);
    }
        public void TestDeleteUserEmpty()
        {
            Repos<User> repos = new Repos<User>();

            repos.Save(new User());

            Assert.IsTrue(repos.Delete(0));
        }
        public void TestDeleteUserFull()
        {
            Repos<User> repos = new Repos<User>();

            repos.Save(new User(111, "Name"));

            Assert.IsTrue(repos.Delete(0));
        }
        public void TestSaveUser()
        {
            Repos<User> repos = new Repos<User>();
            repos.Save(new User(111, "Name"));
            int id = 111;
            string username = "******";

            Assert.AreEqual(id, repos.Get(0).Id);
            Assert.AreEqual(username, repos.Get(0).Username);
        }
        public void TestGetUserName()
        {
            Repos<User> repos = new Repos<User>();
            string username = "******";

            repos.Save(new User("Name"));
            User checkingUser = new User(username);
            User realUser = repos.Get(0);

            Assert.AreEqual(checkingUser.Id, realUser.Id);
            Assert.AreEqual(checkingUser.Username, realUser.Username);
        }
        public void TestGetUserId()
        {
            Repos<User> repos = new Repos<User>();
            int id = 111;

            repos.Save(new User(111));
            User checkingUser = new User(id);
            User realUser = repos.Get(0);

            Assert.AreEqual(checkingUser.Id, realUser.Id);
            Assert.IsNull(realUser.Username);
        }
        public void TestGetUserFull()
        {
            Repos<User> repos = new Repos<User>();
            int id = 111;
            string username = "******";

            repos.Save(new User(111, "Name"));
            User checkingUser = new User(id, username);
            User realUser = repos.Get(0);

            Assert.AreEqual(checkingUser.Id, realUser.Id);
            Assert.AreEqual(checkingUser.Username, realUser.Username);
        }
        public void TestGetAllUsers()
        {
            Repos<User> repos = new Repos<User>();
            List<User> us = new List<User>();

            for (int i = 0; i < 5; i++)
            {
                us.Add(new User(i, "Name" + i));
                repos.Save(new User(i, "Name" + i));
            }

            foreach (User u in repos.GetAll())
            {
                Console.WriteLine(u);
            }

            var n = 0;
            foreach (User s in repos.GetAll())
            {
                Assert.AreEqual(us[n].Id, s.Id);
                Assert.AreEqual(us[n].Username, s.Username);
                n++;
            }
        }