Exemple #1
0
    public IEnumerator Constructor_PieceObj()
    {
        //Load and instantiate target object
        GameObject targetObj = Object.Instantiate(Resources.Load("1/targetObj") as GameObject);
        //Get instance of script
        BreakingEffect BE = targetObj.GetComponent <BreakingEffect>();

        //Call start to initial scene
        BE.Start();
        //UTPieceClass1
        Assert.AreEqual("Cube1", BE.pieceObj[0].obj.name);
        //UTPieceClass2
        Assert.AreEqual(false, BE.pieceObj[0].onGround);
        //UTPieceClass3
        Assert.AreEqual(50, BE.pieceObj[0].initSpeed);
        //UTPieceClass4
        Assert.AreEqual(-9.8, BE.pieceObj[0].gravity, delta);
        //UTPieceClass5
        Assert.AreEqual(false, BE.pieceObj[0].stop);
        //UTPieceClass6
        Assert.AreEqual(29.41, BE.pieceObj[0].speedLastFrameX, delta);
        //UTPieceClass7
        Assert.AreEqual(9.8, BE.pieceObj[0].speedLastFrameZ, delta);
        yield return(null);
    }
Exemple #2
0
    public void OutScoM()
    {
        // Use the Assert class to test conditions.
        BreakingEffect BE = new BreakingEffect();

        // If user input Mu with out of scope value. Get the exception invalid mu.
        Assert.Catch <System.Exception>(() => BE.InputVerify(5, (float)99, GameObject.Find("TargetObj")));
    }
Exemple #3
0
    public void NonNumMu()
    {
        // Use the Assert class to test conditions.
        BreakingEffect BE = new BreakingEffect();

        // If user input mu as non-number value, Unity will consider it as 0 by default. Get the same exception invalid mu.
        Assert.Catch <System.Exception>(() => BE.InputVerify(5, (float)0, GameObject.Find("TargetObj")));
    }
Exemple #4
0
    public void NoExpLv()
    {
        // Use the Assert class to test conditions.
        BreakingEffect BE = new BreakingEffect();

        // If user does not input E, Unity will consider it as 0 by default. Get the same exception invalid E.
        Assert.Catch <System.Exception>(() => BE.InputVerify(0, (float)0.2, GameObject.Find("TargetObj")));
    }
Exemple #5
0
    public void NoObj()
    {
        // Use the Assert class to test conditions.
        BreakingEffect BE = new BreakingEffect();

        //Input a "null" target object
        Assert.Catch <System.NullReferenceException>(() => BE.InputVerify(5, (float)0.2, GameObject.Find("Null")));
    }
Exemple #6
0
    public void OutScoC()
    {
        // Use the Assert class to test conditions.
        BreakingEffect BE = new BreakingEffect();
        // Create a target object that has invalid coordinates.
        GameObject GO = new GameObject();

        GO.transform.position = new Vector3(0, 99999, 0);
        Assert.Catch <System.Exception>(() => BE.InputVerify(5, (float)0.2, GO));
    }
Exemple #7
0
    public IEnumerator UTTarObj1()
    {
        //Load and instantiate target object
        GameObject targetObj = Object.Instantiate(Resources.Load("1/targetObj") as GameObject);
        //Get instance of script
        BreakingEffect BE = targetObj.GetComponent <BreakingEffect>();

        //Call start to initial scene
        BE.Start();
        //Test if target object is successfully created by checking count of sub objects.
        Assert.AreEqual(32, targetObj.transform.childCount);
        yield return(null);
    }
Exemple #8
0
    public IEnumerator testInitialSpeed()
    {
        //Load and instantiate target object
        GameObject targetObj = Object.Instantiate(Resources.Load("1/targetObj") as GameObject);
        //Get instance of script
        BreakingEffect BE = targetObj.GetComponent <BreakingEffect>();

        //Call start to initial scene
        BE.Start();
        //Test if all piece objects are successfully initialed
        Assert.AreEqual(50, BE.pieceObj[0].initSpeed);
        yield return(null);
    }
Exemple #9
0
    public IEnumerator testMotionGround()
    {
        //Load and instantiate target object
        GameObject targetObj = Object.Instantiate(Resources.Load("1/targetObj") as GameObject);
        //Load ground with script
        //Instantiate ground
        GameObject ground = Object.Instantiate(Resources.Load("1/ground") as GameObject);
        //Get instance of script
        BreakingEffect BE = targetObj.GetComponent <BreakingEffect>();

        //Call start to initial scene
        BE.Start();
        //Test displacement on the ground in one frame
        Assert.AreEqual(0.58, BE.pieceObj[0].DisGroCalX(), delta);
        Assert.AreEqual(0.19, BE.pieceObj[0].DisGroCalZ(), delta);
        yield return(null);
    }
Exemple #10
0
    public IEnumerator testAngles2()
    {
        //Load and instantiate target object
        GameObject targetObj = Object.Instantiate(Resources.Load("1/targetObj") as GameObject);
        //Get instance of script
        BreakingEffect BE = targetObj.GetComponent <BreakingEffect>();

        //Call start to initial scene
        BE.Start();
        Debug.Log("Explosion point is: " + BE.GetExplosionPoint());
        Debug.Log("Position of pieceObj[1] is: " + BE.pieceObj[1].obj.transform.position);
        Debug.Log("ThetaOne is: " + BE.pieceObj[1].thetaOne);
        Debug.Log("ThetaTwo is: " + BE.pieceObj[1].thetaTwo);
        Assert.AreEqual(0.76, BE.pieceObj[1].thetaOne, delta);
        Assert.AreEqual(0.79, BE.pieceObj[1].thetaTwo, delta);
        yield return(null);
    }
Exemple #11
0
    public IEnumerator BETestWithEnumeratorPasses()
    {
        // Use the Assert class to test conditions.
        // yield to skip a frame
        GameObject go1 = Resources.Load("1/targetObj") as GameObject;

        Object.Instantiate(go1);
        //Debug.Log(go1.name);
        go1.name           = "targetObj";
        go1.transform.name = "targetObj";
        //Debug.Log(go1.transform.childCount);
        //Debug.Log(GameObject.FindGameObjectWithTag("targetObj").name);
        //Debug.Log(GameObject.Find("targetObj").name);
        GameObject     ground = Resources.Load("1/ground") as GameObject;
        BreakingEffect BE     = ground.GetComponent <BreakingEffect>();

        BE.Start();
        Assert.AreEqual(32, BE.pieceObj.Length);
        yield return(null);
    }
Exemple #12
0
 public void CorrectIn()
 {
     // Use the Assert class to test conditions.
     BreakingEffect BE = new BreakingEffect();
 }