-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestAppleTree.cs
More file actions
36 lines (28 loc) · 1.61 KB
/
TestAppleTree.cs
File metadata and controls
36 lines (28 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using UnityEngine;
using beyondnations;
namespace beyondnationstests {
public static class TestTree {
public static void runTests() {
testInstantiation();
}
public static void testInstantiation() {
// run
int height = 5;
AppleTree tree = new AppleTree(new Vector3(0, 0, 0), height);
// check - verify tree is created with proper structure
UnityEngine.Debug.Assert(tree.getType() == EntityType.TREE);
UnityEngine.Debug.Assert(tree.getGameObject().name == "AppleTree");
UnityEngine.Debug.Assert(tree.getGameObject().transform.position == new Vector3(0, 0, 0));
UnityEngine.Debug.Assert(tree.getGameObject().transform.childCount == 2);
UnityEngine.Debug.Assert(tree.getGameObject().transform.GetChild(0).name == "Trunk");
UnityEngine.Debug.Assert(tree.getGameObject().transform.GetChild(1).name == "Leaves");
// Verify trunk and leaves have MeshFilter and MeshRenderer components (3D model)
UnityEngine.Debug.Assert(tree.getGameObject().transform.GetChild(0).GetComponent<MeshFilter>() != null);
UnityEngine.Debug.Assert(tree.getGameObject().transform.GetChild(0).GetComponent<MeshRenderer>() != null);
UnityEngine.Debug.Assert(tree.getGameObject().transform.GetChild(1).GetComponent<MeshFilter>() != null);
UnityEngine.Debug.Assert(tree.getGameObject().transform.GetChild(1).GetComponent<MeshRenderer>() != null);
// clean up
GameObject.Destroy(tree.getGameObject());
}
}
}