[Timeout(5000)]  // タイムアウトは5秒(5000ms)
    public IEnumerator TestSphereScaleWithFixedRandomizer()
    {
        float targetScale = 0.45678f;

        // InjectされるRandomizer
        StaticContext.Container
        .BindInterfacesAndSelfTo <FixedRandomizer>()
        .AsSingle()
        .WithArguments <float>(targetScale);

        // シーンの読み込み
        yield return(LoadScene(sceneName));

        var resolved = SceneContainer.Resolve <IRandomizer>();

        Assert.IsInstanceOf <FixedRandomizer>(resolved);

        // テスト対象のGeameObjectを取得
        var targetObject = GameObject.Find("RandomScaleSphere");

        yield return(null);  // 1frame動かす

        // Start()後のスケールを確認
        Vector3 localScale = targetObject.transform.localScale;

        Assert.AreEqual(new Vector3(targetScale, targetScale, targetScale), localScale);
    }
コード例 #2
0
        private void UpdateScore(int numberOfUpdates)
        {
            var scoreProcessor = SceneContainer.Resolve <ScoreProcessor>();

            for (int i = 0; i < numberOfUpdates; i++)
            {
                scoreProcessor.UpdateScore();
            }
        }
コード例 #3
0
        public IEnumerator UpdateScore_LinesTextIsUpdated([Values(0, 1, 2, 3, 4, 5)] int numberOfUpdates)
        {
            yield return(LoadScene("Game"));

            var scoreText  = GameObject.Find("LinesText").GetComponent <TMP_Text>();
            var scoreModel = SceneContainer.Resolve <ScoreModel>();

            UpdateScore(numberOfUpdates);
            Assert.AreEqual((scoreModel.CurrentLinesCount).ToString(), scoreText.text);
        }
コード例 #4
0
ファイル: SceneTest.cs プロジェクト: Maggotya/Galcon
        private IEnumerator Install()
        {
            yield return(LoadScene("Game"));

            _camera = Camera.main;

            _gameManager      = SceneContainer.Resolve <GameManager>();
            _levelManager     = SceneContainer.Resolve <ILevelManager>();
            _player           = _levelManager?.gameObject?.GetComponentInChildren <IPlayer>();
            _planetOwner      = _player?.gameObject?.GetComponent <IPlanetOwner>();
            _selectionManager = _player?.gameObject?.GetComponentInChildren <ISelectionManager>();
            _planetManager    = _levelManager?.gameObject?.GetComponentInChildren <IPlanetsManager>();

            _gameManager.StartGame();
        }
コード例 #5
0
        public IEnumerator TestEnemyStateChanges()
        {
            // Override settings to only spawn one enemy to test
            StaticContext.Container.BindInstance(
                new EnemySpawner.Settings()
            {
                SpeedMin               = 50,
                SpeedMax               = 50,
                AccuracyMin            = 1,
                AccuracyMax            = 1,
                NumEnemiesIncreaseRate = 0,
                NumEnemiesStartAmount  = 1,
            });

            yield return(LoadScene(SceneName));

            var enemy = SceneContainer.Resolve <EnemyRegistry>().Enemies.Single();

            // Should always start by chasing the player
            Assert.IsEqual(enemy.State, EnemyStates.Follow);

            // Wait a frame for AI logic to run
            yield return(null);

            // Our player mock is always at position zero, so if we move the enemy there then the enemy
            // should immediately go into attack mode
            enemy.Position = Vector3.zero;

            // Wait a frame for AI logic to run
            yield return(null);

            Assert.IsEqual(enemy.State, EnemyStates.Attack);

            enemy.Position = new Vector3(100, 100, 0);

            // Wait a frame for AI logic to run
            yield return(null);

            // The enemy is very far away now, so it should return to searching for the player
            Assert.IsEqual(enemy.State, EnemyStates.Follow);
        }
コード例 #6
0
        public IEnumerator TestKillsPlayer()
        {
            // Override settings to only spawn one enemy to test
            StaticContext.Container.BindInstance(
                new EnemySpawner.Settings()
            {
                SpeedMin               = 50,
                SpeedMax               = 50,
                AccuracyMin            = 1,
                AccuracyMax            = 1,
                NumEnemiesIncreaseRate = 0,
                NumEnemiesStartAmount  = 5,
            });

            yield return(LoadScene(SceneName));

            var signalBus = SceneContainer.Resolve <SignalBus>();

            bool died = false;

            signalBus.Subscribe <PlayerDiedSignal>(() => died = true);

            var startTime = Time.realtimeSinceStartup;

            while (!died && Time.realtimeSinceStartup - startTime < 30.0f)
            {
                yield return(null);
            }

            startTime = Time.realtimeSinceStartup;

            // Wait for death sequence to pass
            while (Time.realtimeSinceStartup - startTime < 2.0f)
            {
                yield return(null);
            }

            Assert.That(died, "Enemy could not kill player in 30 seconds or less!");
        }
コード例 #7
0
    public IEnumerator ShowPopupsOverEachOther()
    {
        yield return(LoadScene("PopupsModule.Tests.Playmode.MainScene"));

        var signalBus = SceneContainer.Resolve <SignalBus>();

        popupsViewManager = SceneContainer.Resolve <IPopupsViewManager <PopupEntityBase> >();
        signalBus.Subscribe <LoadPopupAssetRequest>(OnAssetShouldBeLoadedCallback);
        var containerWithPopups = GameObject.FindObjectOfType <TestPopupsContainer>();

        cachedPopups = containerWithPopups.GetPopups();


        for (int i = 0; i < cachedPopups.Count; i++)
        {
            var popupData = new PopupEntityWithId(cachedPopups[i].gameObject.name, PopupRuleKeys.ForceShowRule)
            {
                PopupData = null,
            };

            popupsViewManager.Open(popupData, OnSuccess, OnFail);
            yield return(new WaitForSeconds(1f));
        }

        yield return(new WaitForSeconds(3f));

        while (popupsViewManager.CurrentOpenedPopup != null)
        {
            popupsViewManager.CurrentOpenedPopup.Hide();
            yield return(new WaitForSeconds(1f));
        }

        yield return(new WaitForSeconds(3));
        // TODO: Add assertions here now that the scene has started
        // Or you can just uncomment to simply wait some time to make sure the scene plays without errors
        //yield return new WaitForSeconds(1.0f);

        // Note that you can use SceneContainer.Resolve to look up objects that you need for assertions
    }