コード例 #1
0
    [SetUp] //called at the start of each test
    public void Setup()
    {
        pmanager = GameObject.Find("GameManager").GetComponent <PlantManager>();

        pmanager.prefabMappings.Clear();
        pmanager.allPrefabs.Clear();


        pmanager.activePlants = new GameObject[pmanager.maxActivePlants];

        pmanager.allPrefabs.Add("Aloe");
        pmanager.allPrefabs.Add("Jade");
        pmanager.allPrefabs.Add("Echeveria");
        pmanager.allPrefabs.Add("Basic Plant");

        int i = 0;

        foreach (string prefab in pmanager.allPrefabs)
        {
            GameObject plant = (GameObject)Resources.Load(PlantManager.prefabPath + prefab);
            pmanager.prefabMappings.Add(prefab, plant);

            GameObject testPlant = pmanager.MakePlant("tester" + i.ToString(), prefab);

            if (i < pmanager.maxActivePlants)
            {
                pmanager.SetPlantStatus(testPlant, true);
            }
            plantRates.Add(testPlant.GetComponent <PlantRates>());

            i++;
        }
    }
コード例 #2
0
    public void MakePlantTest1()
    {
        string     name     = "TestPlant1";
        GameObject newPlant = pmanager.MakePlant(name, "Aloe");

        Assert.IsFalse(pmanager.plantCollection.Count == 0, String.Format("Plant wass added, the length should be 1. Got {0}", pmanager.plantCollection.Count));
        Assert.IsFalse(pmanager.PlantActive(newPlant), String.Format("Plant '{0}' was added. It should not be active but it was", newPlant.name));
        Assert.IsTrue(newPlant.name == name, String.Format("Plant '{0}' was added. It should be called {0} but it was called {1}", name, newPlant.name));
    }