Exemplo n.º 1
0
        public void GivenShowAllTilesAllowTouchFalse_WhenExecute_ThenDoNotShowAllMatchTiles()
        {
            matchTileGridModel.allowTouch = false;

            MatchTile matchTile = new MatchTile();

            matchTile.canTouch   = true;
            matchTile.position   = Vector2.zero;
            matchTile.tileObject = new GameObject();

            Dictionary <Vector2, MatchTile> matchTilesDic = new Dictionary <Vector2, MatchTile> ();

            matchTilesDic [matchTile.position] = matchTile;

            matchTileGridModel.GetMatchTiles().Returns(matchTilesDic);

            IMatchTileComponent matchTileComponenet = Substitute.For <IMatchTileComponent> ();

            matchTileGridModel.GetMatchTileComponent(Arg.Any <MatchTile>()).Returns(matchTileComponenet);

            hideInvalidTilesCommand.hideType = HideType.ShowAll;
            hideInvalidTilesCommand.Execute();

            matchTileComponenet.DidNotReceive().Show();
        }
Exemplo n.º 2
0
        private void HighLight(MatchTile tile)
        {
            IMatchTileComponent matchTileComponent = matchTileGridModel.GetMatchTileComponent(tile);

            if (matchTileComponent != null)
            {
                matchTileComponent.HighLight();
            }
        }
Exemplo n.º 3
0
        private void DisplayHint()
        {
            List <MatchTile> hintMatchTiles = matchTileGridModel.GetHintMatchTiles();

            for (int i = 0; i < hintMatchTiles.Count; i++)
            {
                MatchTile tile = hintMatchTiles [i];

                IMatchTileComponent matchTileComponent = matchTileGridModel.GetMatchTileComponent(tile);
                matchTileComponent.Hint(i);
            }
        }
Exemplo n.º 4
0
        private void ShowAllTiles()
        {
            Dictionary <Vector2, MatchTile> matchTiles = matchTileGridModel.GetMatchTiles();

            foreach (KeyValuePair <Vector2, MatchTile> entry in matchTiles)
            {
                MatchTile           tile = entry.Value;
                IMatchTileComponent matchTileComponent = matchTileGridModel.GetMatchTileComponent(tile);
                if (matchTileComponent != null)
                {
                    matchTileComponent.Show();
                }
            }
        }
Exemplo n.º 5
0
        private void HideNotValidTiles()
        {
            List <MatchTile> matchTiles = matchTileGridModel.GetAllMatchTilesNotOfType(type);

            for (int i = 0; i < matchTiles.Count; i++)
            {
                MatchTile           tile = matchTiles [i];
                IMatchTileComponent matchTileComponent = matchTileGridModel.GetMatchTileComponent(tile);
                if (matchTileComponent != null)
                {
                    matchTileComponent.Hide();
                }
            }
        }
Exemplo n.º 6
0
        private void DisplayTiles(List <MatchTile> tilesTouched)
        {
            for (int i = 0; i < tilesTouched.Count; i++)
            {
                MatchTile tile = tilesTouched [i];

                if (tile.tileObject != null)
                {
                    IMatchTileComponent matchTileComponent = matchTileGridModel.GetMatchTileComponent(tile);
                    if (matchTileComponent != null)
                    {
                        matchTileComponent.Tile();
                    }
                }
            }
        }
Exemplo n.º 7
0
        public void GivenMatchTilesTouched_WhenExecute_ThenMatchTileComponentTileMethodCalled()
        {
            MatchTile matchTile = new MatchTile();

            matchTile.canTouch   = true;
            matchTile.position   = Vector2.zero;
            matchTile.tileObject = new GameObject();

            List <MatchTile> matchTiles = new List <MatchTile>();

            matchTiles.Add(matchTile);
            matchTileGridModel.GetTilesTouched().Returns(matchTiles);

            IMatchTileComponent matchTileComponenet = Substitute.For <IMatchTileComponent> ();

            matchTileGridModel.GetMatchTileComponent(Arg.Any <MatchTile>()).Returns(matchTileComponenet);

            removeMatchTileHightLightCommand.Execute();

            matchTileComponenet.Received().Tile();
        }
Exemplo n.º 8
0
        public void GivenCanTouchTile_WhenTouchObjectExecute_ThenHighLightMatchTileComponent()
        {
            matchTileGridModel.allowTouch = true;

            IMatchTileComponent matchTileComponenet = Substitute.For <IMatchTileComponent> ();

            matchTileGridModel.GetMatchTileComponent(Arg.Any <MatchTile>()).Returns(matchTileComponenet);

            MatchTile matchTile = new MatchTile();

            matchTile.canTouch   = true;
            matchTile.position   = Vector2.zero;
            matchTile.tileObject = new GameObject();

            matchTileGridModel.GetMatchTile(Vector2.zero).Returns(matchTile);
            matchTileGridModel.CanTouchTile(matchTile).Returns(true);

            matchTileTouchedCommand.Execute();

            matchTileComponenet.Received().HighLight();
        }
Exemplo n.º 9
0
        public void GivenGetHintMatchTilesReturnsList_WhenExecuteDisplayHint_ThenMatchTileComponentHint()
        {
            List <MatchTile> hintMatchTiles = new List <MatchTile> ();

            hintMatchTiles.Add(new MatchTile());

            matchTileGridModel.GetHintMatchTiles().Returns(hintMatchTiles);

            IMatchTileComponent matchTileComponenet = Substitute.For <IMatchTileComponent> ();

            matchTileGridModel.GetMatchTileComponent(Arg.Any <MatchTile>()).Returns(matchTileComponenet);

            matchTileGridModel.lastTouchedTimestamp = Time.time - 10;
            matchTileHintCommand.Execute();

            IEnumerator iEnum = matchTileHintCommand.enumerator;

            iEnum.MoveNext();
            iEnum.MoveNext();

            matchTileComponenet.Received().Hint(Arg.Any <int>());
        }
Exemplo n.º 10
0
        public void GivenHideNotValidTiles_WhenExecute_ThenHideAllMatchTilesNotOfType()
        {
            MatchTile matchTile = new MatchTile();

            matchTile.canTouch   = true;
            matchTile.position   = Vector2.zero;
            matchTile.tileObject = new GameObject();

            List <MatchTile> matchTiles = new List <MatchTile>();

            matchTiles.Add(matchTile);
            matchTileGridModel.GetTilesTouched().Returns(matchTiles);

            IMatchTileComponent matchTileComponenet = Substitute.For <IMatchTileComponent> ();

            matchTileGridModel.GetMatchTileComponent(Arg.Any <MatchTile>()).Returns(matchTileComponenet);

            matchTileGridModel.GetAllMatchTilesNotOfType(Arg.Any <MatchTileType> ()).Returns(matchTiles);

            hideInvalidTilesCommand.hideType = HideType.NotValidTiles;
            hideInvalidTilesCommand.Execute();

            matchTileComponenet.Received().Hide();
        }