public IEnumerator CorrectMapLoading() { SceneManager.LoadScene("Scene", LoadSceneMode.Single); yield return(new WaitForSeconds(1.0f)); goA = SceneManager.GetActiveScene().GetRootGameObjects(); GameObject go = goA[3].transform.Find("Save Load Menu").gameObject; SaveLoadMenu slm = go.GetComponent <SaveLoadMenu>(); GameObject go2 = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/UI/Save Load Item")); SaveLoadItem sli = go2.GetComponent <SaveLoadItem>(); sli.MapName = "test16"; sli.menu = slm; slm.itemPrefab = sli; sli.Select(); slm.hexGrid = goA[1].GetComponent <HexGrid>(); slm.Open(true); slm.Action(); slm.Open(false); slm.Action(); string[] paths = Directory.GetFiles(Application.persistentDataPath, "*.map"); bool b = false; for (int i = 0; i < paths.Length; i++) { if (Path.GetFileNameWithoutExtension(paths[i]) == sli.MapName) { b = true; break; } } Assert.IsTrue(b); foreach (GameObject g in goA) { GameObject.Destroy(g); } GameObject.Destroy(go); GameObject.Destroy(slm); GameObject.Destroy(go2); GameObject.Destroy(sli); SceneManager.UnloadScene("Scene"); }
public IEnumerator DeleteMapFromMenuList() { SceneManager.LoadScene("Scene", LoadSceneMode.Single); yield return(new WaitForSeconds(1.0f)); goA = SceneManager.GetActiveScene().GetRootGameObjects(); GameObject go = goA[3].transform.Find("Save Load Menu").gameObject; SaveLoadMenu slm = go.GetComponent <SaveLoadMenu>(); string[] paths = Directory.GetFiles(Application.persistentDataPath, "*.map"); slm.SelectItem("test3"); slm.hexGrid = goA[1].GetComponent <HexGrid>(); slm.Open(true); slm.Action(); int MapCount = slm.listContent.childCount; slm.Delete(); for (int i = 0; i < slm.listContent.childCount; i++) { for (int j = 0; j < paths.Length; j++) { if (slm.listContent.GetChild(i).gameObject.GetComponent <SaveLoadItem>().MapName != "test3") { Assert.IsTrue(true); yield return(null); } } } Assert.IsFalse(false); foreach (GameObject g in goA) { GameObject.Destroy(g); } GameObject.Destroy(go); GameObject.Destroy(slm); SceneManager.UnloadScene("Scene"); }
public IEnumerator ReturnNullIfFileDontExistsDuringTheLoading() { SceneManager.LoadScene("Scene", LoadSceneMode.Single); yield return(new WaitForSeconds(1.0f)); goA = SceneManager.GetActiveScene().GetRootGameObjects(); GameObject go = goA[3].transform.Find("Save Load Menu").gameObject; SaveLoadMenu slm = go.GetComponent <SaveLoadMenu>(); slm.SelectItem("test6"); slm.Open(false); slm.Action(); Assert.IsNull(slm.path); foreach (GameObject g in goA) { GameObject.Destroy(g); } GameObject.Destroy(go); GameObject.Destroy(slm); SceneManager.UnloadScene("Scene"); }