public IEnumerator TC16UpdateLeadershipboardDetails_User() { bool foundUser = false; int userOriginalLevel = 1; // set dummy data for user account UserData userData = new UserData(); userData.userName = "******"; GameObject mainMenuGameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/MainMenuController")); MainMenuControllerScript mainMenuControllerScript = mainMenuGameObject.GetComponent <MainMenuControllerScript>(); mainMenuControllerScript.setUserData(userData); // initialized leadership board canvas and get the view model script attached to it GameObject leadershipGameObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/LeadershipBoardCanvas")); LeadershipViewModel leadershipViewModel = leadershipGameObject.transform.Find("Backboard").Find("RankingScrollView"). Find("Scroll Rect").Find("RankingContent").GetComponent <LeadershipViewModel>(); leadershipViewModel.mainMenuControllerScript = mainMenuControllerScript; // upload dummy data for peter RestClient.Put($"{databaseURL}score/{userData.userName}/levelScore/1.json", 5.ToString()); yield return(new WaitForSeconds(2)); // stimulate enter leadershipboard page leadershipGameObject.SetActive(true); yield return(new WaitForSeconds(2)); // iterate thru the UI table via each row to see if can find the user's username means his result can be found in the leadershipboard foreach (GameObject item in leadershipViewModel.getInstantiatedUI()) { if (item.transform.GetChild(1).GetComponent <Text>().text.Equals(userData.userName)) { foundUser = true; userOriginalLevel = Int32.Parse(item.transform.GetChild(2).GetComponent <Text>().text); // since found user, no point looping further break; } } // check if found user in leadershipboard Assert.IsTrue(foundUser); // stimulate leaving leadershipboard page leadershipGameObject.SetActive(false); // upload dummy data for peter as if he completed new level // using userOriginalLevel to increment incase already have "peter" in database and his original score might be even higher than value of 1 RestClient.Put($"{databaseURL}score/{userData.userName}/levelScore/{userOriginalLevel + 1}.json", 5.ToString()); yield return(new WaitForSeconds(2)); // stimulate enter leadershipboard page leadershipGameObject.SetActive(true); yield return(new WaitForSeconds(2)); // reset boolean variable foundUser = false; // iterate thru the UI table via each row to see if can find the user's username means his result can be found in the leadershipboard foreach (GameObject item in leadershipViewModel.getInstantiatedUI()) { // check if found user if (item.transform.GetChild(1).GetComponent <Text>().text.Equals(userData.userName)) { Assert.AreNotEqual(userOriginalLevel, Int32.Parse(item.transform.GetChild(2).GetComponent <Text>().text)); foundUser = true; } } // check if found user in leadershipboard Assert.IsTrue(foundUser); }
/// <summary> /// This function is use to allow the user to login when the user click on the Login button. Checks will be done by the server to verify the user before logging him/her in /// </summary> public async void login() { string email = emailInput.text.Trim().ToLower(); string password = passwordInput.text; Debug.Log(email); Debug.Log(password); if ((email == "" || email == null) && (password == "" || password == null)) { Debug.Log("Email Password not filled"); StartCoroutine(EmailPasswordNotFill()); } else { if (email == "" || email == null) { Debug.Log("Email not filled"); StartCoroutine(EmailNotFill()); } else { if (password == "" || password == null) { Debug.Log("Password not filled"); StartCoroutine(PassNotFill()); } else { Debug.Log(email); Debug.Log(password); Debug.Log("entering loginChk"); string loginChk = await PostRequest(email, password); Debug.Log("exited loginChk. Value below."); Debug.Log(loginChk); if (loginChk != null) { Debug.Log("loginChk is not null"); studentChk = await ChkStudent(loginChk); Debug.Log("studenChk exited"); if (studentChk == true) { Debug.Log("studentChk true"); Debug.Log(userData.userName); mainMenuController.setUserData(userData); mainMenuController.loadMainMenu(); UIController.loginButton(); } else { Debug.Log("Wrong User Pass"); StartCoroutine(ShowWrongMessage()); } } else { Debug.Log("Wrong User Pass"); StartCoroutine(ShowWrongMessage()); } } } } }