コード例 #1
0
    protected void SetUp()
    {
        RenderProfileManifest.i.Initialize();

        sceneHandler = Substitute.For <ISceneHandler>();

        var allLoadedParcelCoords = new HashSet <Vector2Int>();

        allLoadedParcelCoords.Add(new Vector2Int(0, 0));
        allLoadedParcelCoords.Add(new Vector2Int(-1, 0));
        allLoadedParcelCoords.Add(new Vector2Int(-1, 1));

        sceneHandler.GetAllLoadedScenesCoords().Returns(allLoadedParcelCoords);

        var animationHandler = Substitute.For <IBlockerAnimationHandler>();

        //NOTE(Brian): Call OnFinish() when blockerAnimationHandler.FadeOut is called.
        animationHandler.FadeOut(Arg.Any <GameObject>(), Arg.Invoke());

        var newBlockerInstanceHandler = new BlockerInstanceHandler();

        newBlockerInstanceHandler.Initialize(animationHandler);

        blockerInstanceHandler = newBlockerInstanceHandler;
        blockersParent         = new GameObject();
        blockerInstanceHandler.SetParent(blockersParent.transform);

        blockerController = new WorldBlockersController();
        blockerController.Initialize(sceneHandler, blockerInstanceHandler);
    }
コード例 #2
0
    public void SetupBlockersOnlyWhenEnabled()
    {
        // Arrange
        blockerInstanceHandler = Substitute.For <IBlockerInstanceHandler>();
        blockerInstanceHandler.GetBlockers().Returns(new Dictionary <Vector2Int, PoolableObject>());

        if (blockerController != null)
        {
            blockerController.Dispose();
        }

        blockerController.Initialize(sceneHandler, blockerInstanceHandler);

        // Act-assert #1: first blockers added should be shown
        blockerController.SetupWorldBlockers();
        blockerInstanceHandler.ReceivedWithAnyArgs().ShowBlocker(default);