コード例 #1
0
    public IEnumerator BallBouncesFromBoardBounds()
    {
        _setup.DestroyAll();
        GameObject ball = _setup.CreateBallForTest();

        ball.GetComponent <Ball>().SetSpeed(0, 1);
        Camera cam  = _setup.CreateCameraForTest();
        float  time = 0;

        while (time < 5)
        {
            ball.GetComponent <Ball>().Move();
            time += Time.deltaTime;
        }
        yield return(new WaitForFixedUpdate());

        Assert.Less(ball.transform.position.y, 5);
    }
コード例 #2
0
ファイル: BallTests.cs プロジェクト: sophiaaar/tdd-pong
    public IEnumerator BallCanMoveIn2d()
    {
        _setup.DestroyAll();
        GameObject ball = _setup.CreateBallForTest();

        _setup.CreateCameraForTest();
        Vector2 original = new Vector2(ball.transform.position.x, ball.transform.position.y);

        ball.GetComponent <Ball>().SetSpeed(1, -1);
        yield return(null);

        Vector2 current = new Vector2(ball.transform.position.x, ball.transform.position.y);

        Assert.AreNotEqual(original, current);
    }