コード例 #1
0
        public void movementOutOfNegativeBounds_accessNotGranted_False()
        {
            var mockCharacter = new Character();
            var mockTile      = new MockTile(mockCharacter, 3, 3, 1, 1);

            var movement = mockCharacter.Move(mockTile, ICreature.direction.S) as ITile;

            Assert.True(mockTile.X == movement.X && mockTile.Y == movement.Y);
        }
コード例 #2
0
        public void movementWithinPositiveBoundsSoutheastwards_accessGranted_True()
        {
            var mockCharacter = new Character();
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);

            var movement = mockCharacter.Move(mockTile, ICreature.direction.SE) as ITile;

            Assert.True(movement.X != mockTile.X || movement.Y != mockTile.Y);
        }
コード例 #3
0
        public void TestContains()
        {
            var   ts = new TilesMap();
            ITile a  = new MockTile("a");

            Assert.That(ts.Contains("a"), Is.False);

            ts.AddTile(a);

            Assert.That(ts.Contains("a"), Is.True);
        }
コード例 #4
0
        public void SameTileShouldBeReturned()
        {
            var   ts = new TilesMap();
            ITile a  = new MockTile("a");
            ITile b  = new MockTile("b");

            ts.AddTile(a);
            ts.AddTile(b);

            Assert.That(ts.Get("a"), Is.SameAs(a));
            Assert.That(ts.Get("b"), Is.SameAs(b));
        }
コード例 #5
0
        public void TestCache()
        {
            var   ts = new TilesMap();
            ITile a  = new MockTile("a");
            ITile b  = new MockTile("b");

            ts.AddTile(a);
            ts.AddTile(b);

            Assert.That(ts.Get("a"), Is.SameAs(a));
            Assert.That(ts.Get("b"), Is.SameAs(b));
        }
コード例 #6
0
        public void ArchaeopteryxMove_edgeOfLevelAchieved_returnsTheSameTile()
        {
            var mockCharacter     = new Character();
            var mockArchaeopteryx = new Archaeopteryx();

            mockCharacter.CreditArchaeopteryx(mockArchaeopteryx);
            var mockTile = new MockTile(mockCharacter, 3, 3, 3, 3);

            var destination = mockArchaeopteryx.OnMovement(mockCharacter, mockTile, null, ICreature.direction.NW);

            Assert.Equal(mockTile, destination);
        }
コード例 #7
0
        public void ArchaeopteryxOpened_TerritoryIsAccessible_True()
        {
            var mockCharacter = new Character();

            mockCharacter.CreditArchaeopteryx(new Archaeopteryx());
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);
            var mockTerritory = new MockHiddenTerritory(mockCharacter, new Archaeopteryx(), mockTile);

            mockTerritory.OpenTerritory(mockCharacter);
            var territoryIsAccessible = mockTerritory.isAccessible;

            Assert.True(territoryIsAccessible);
        }
コード例 #8
0
        public void ArchaeopteryxUs_FriendlinessIncreased_AnchiornisMoreAttracted()
        {
            var mockCharacter     = new Character();
            var mockArchaeopteryx = new Archaeopteryx();

            mockCharacter.CreditArchaeopteryx(mockArchaeopteryx);
            var mockFriendlyAnchiornis = new Anchiornis();
            var mockTile = new MockTile(mockCharacter, 3, 3, 2, 2);

            mockArchaeopteryx.OnUs(mockCharacter, mockFriendlyAnchiornis, mockTile);

            Assert.Equal(12, mockFriendlyAnchiornis.friendliness);
        }
コード例 #9
0
        public void ArchaeopteryxTiles_territoryUnlocked_returnsAccessible()
        {
            var mockCharacter     = new Character();
            var mockArchaeopteryx = new Archaeopteryx();

            mockCharacter.CreditArchaeopteryx(mockArchaeopteryx);
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);
            var mockTerritory = new MockHiddenTerritory(mockCharacter, mockArchaeopteryx, mockTile);

            mockArchaeopteryx.OnTile(mockCharacter, mockTerritory);

            Assert.True(mockTerritory.isAccessible);
        }
コード例 #10
0
        public void ArchaeopteryxUsed_coolDownIncreased_coolDownEqualsCoolDownLimit()
        {
            var mockCharacter     = new Character();
            var mockArchaeopteryx = new Archaeopteryx();

            mockCharacter.CreditArchaeopteryx(mockArchaeopteryx);
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);
            var mockTerritory = new MockHiddenTerritory(mockCharacter, mockArchaeopteryx, mockTile);

            mockArchaeopteryx.OnTile(mockCharacter, mockTerritory);

            Assert.Equal(mockArchaeopteryx.coolDown, mockArchaeopteryx.coolDownTime);
        }
コード例 #11
0
        public void ArchaeopteryxNotUsed_CharacterDoesNotEnterTerritory_CharacterIsNotInCreatures()
        {
            var mockCharacter = new Character();

            mockCharacter.CreditArchaeopteryx(new Archaeopteryx());
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);
            var mockTerritory = new MockHiddenTerritory(mockCharacter, new Archaeopteryx(), mockTile);

            mockTerritory.EnterTerritory(mockCharacter);
            var characterMoved = mockTerritory.creatures.Contains(mockCharacter);

            Assert.False(characterMoved);
        }
コード例 #12
0
        public void ClosingTerritory_TerritoryIsNotAccessibleAnymore_False()
        {
            var mockCharacter = new Character();

            mockCharacter.CreditArchaeopteryx(new Archaeopteryx());
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);
            var mockTerritory = new MockHiddenTerritory(mockCharacter, new Archaeopteryx(), mockTile);

            mockTerritory.OpenTerritory(mockCharacter);
            mockTerritory.CloseTerritory(mockCharacter);
            var territoryIsAccessible = mockTerritory.isAccessible;

            Assert.False(territoryIsAccessible);
        }
コード例 #13
0
        public void ArchaeopteryxOpened_CharacterEntersTerritory_CharacterInCreatures()
        {
            var mockCharacter = new Character();

            mockCharacter.CreditArchaeopteryx(new Archaeopteryx());
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);
            var mockTerritory = new MockHiddenTerritory(mockCharacter, new Archaeopteryx(), mockTile);

            mockTerritory.OpenTerritory(mockCharacter);
            mockTerritory.EnterTerritory(mockCharacter);
            var characterMoved = mockTerritory.creatures.Contains(mockCharacter);

            Assert.True(characterMoved);
        }
コード例 #14
0
        public void ArchaeopteryxMove_successfulStart_returnsFinalDestination()
        {
            var mockCharacter     = new Character();
            var mockArchaeopteryx = new Archaeopteryx();

            mockCharacter.CreditArchaeopteryx(mockArchaeopteryx);
            var mockTile = new MockTile(mockCharacter, 3, 3, 1, 1);

            var destination       = mockArchaeopteryx.OnMovement(mockCharacter, mockTile, null, ICreature.direction.NE) as ITile;
            var xRaised           = destination.X == 3;
            var yRaised           = destination.Y == 3;
            var movementPerformed = xRaised && yRaised;

            Assert.True(movementPerformed);
        }
コード例 #15
0
        public void ArchaeopteryxMove_edgeOfLevelIsMidway_returnsMidway()
        {
            var mockCharacter     = new Character();
            var mockArchaeopteryx = new Archaeopteryx();

            mockCharacter.CreditArchaeopteryx(mockArchaeopteryx);
            var mockTile = new MockTile(mockCharacter, 3, 3, 2, 2);

            var destination       = mockArchaeopteryx.OnMovement(mockCharacter, mockTile, null, ICreature.direction.NE) as ITile;
            var xRaised           = destination.X == 3;
            var yRaised           = destination.Y == 3;
            var movementPerformed = xRaised && yRaised;

            Assert.True(movementPerformed);
        }
コード例 #16
0
    void init2()
    {
        for (int i = 0; i < 1000; i++)
        {
            for (int j = 0; j < 1000; j++)
            {
                var tempTilePos = new Vector2(i, j);
                var tempTile    = new MockTile(Vector2.up, 2, false);
                tileSet2.Add(tempTilePos, tempTile);
            }
        }
        var randTile = new Vector2Int(Random.Range(0, 1000), Random.Range(0, 1000));

        Debug.Log("Tile: " + randTile + " : " + tileSet2[randTile].doorPos + " : " + tileSet2[randTile].doorPos + " : " + tileSet2[randTile].hasBoss);
        Debug.Log("Tile Count: " + tileSet2.Count);
    }
コード例 #17
0
        public void AnExceptionShouldBeThrownWhenEnteringWithTheSameName()
        {
            var   ts = new TilesMap();
            ITile a  = new MockTile("a");
            ITile b  = new MockTile("a");

            ts.AddTile(a);
            try
            {
                ts.AddTile(b);
                Assert.Fail("Expected exception");
            } catch (TileException Te)
            {
                Assert.That(Te.Message, Is.EqualTo(TileException.DoubleDefinition("a").Message));
            }
        }
コード例 #18
0
        public void GetTile_ByCoordinate_ReturnsTile()
        {
            var coordinate = new MockCoordinate();
            var tile       = new MockTile().CoordinateReturns(coordinate);
            var tiles      = new List <ITile> {
                new MockTile().CoordinateReturns(new MockCoordinate()),
                tile,
                new MockTile().CoordinateReturns(new MockCoordinate())
            };
            var boardService = new MockBoardService().GenerateTilesWithCoordinatesReturns(tiles);
            var board        = BuildBoard(boardService: boardService);

            var actual = board.GetTileBy(coordinate);

            Assert.Equal(tile, actual);
            tile.VerifyCoordinateCalled();
        }
コード例 #19
0
        public void GetTile_ByPosition_ReturnsTile()
        {
            const int POSITION = 7;
            var       tile     = new MockTile().PositionReturns(POSITION);
            var       tiles    = new List <ITile> {
                tile,
                new MockTile().CoordinateReturns(new MockCoordinate()),
                new MockTile().CoordinateReturns(new MockCoordinate())
            };
            var boardService = new MockBoardService().GenerateTilesWithCoordinatesReturns(tiles);
            var board        = BuildBoard(boardService: boardService);

            var actual = board.GetTileBy(POSITION);

            Assert.Equal(tile, actual);
            tile.VerifyPositionCalled();
        }
コード例 #20
0
        public void ArchaeopteryxOpened_PackEntersTerritory_PackInCreatures()
        {
            var mockCharacter = new Character();

            mockCharacter.CreditArchaeopteryx(new Archaeopteryx());
            var mockAnchiornis = new Anchiornis();

            mockAnchiornis.IncreaseFriendliness(25);
            mockCharacter.AddToPack(mockAnchiornis);
            var mockTile      = new MockTile(mockCharacter, 3, 3, 2, 2);
            var mockTerritory = new MockHiddenTerritory(mockCharacter, new Archaeopteryx(), mockTile);

            mockTerritory.OpenTerritory(mockCharacter);
            mockTerritory.EnterTerritory(mockCharacter);
            var packMoved = mockTerritory.creatures.Contains(mockAnchiornis);

            Assert.True(packMoved);
        }
コード例 #21
0
        public void enemyMoving_enemyFailed_False()
        {
            var mockCharacter  = new Character();
            var mockAnchiornis = new Anchiornis();
            var mockTile       = new MockTile(mockCharacter, 3, 3, 2, 2);

            mockTile.creatures = new List <ICreature>()
            {
                mockCharacter, mockAnchiornis
            };

            var movement = mockCharacter.Move(mockTile, ICreature.direction.N) as ITile;

            mockAnchiornis.Move(mockTile, movement, false);
            bool enemyMoved = movement.creatures.Contains(mockAnchiornis) ? true : false;

            Assert.False(enemyMoved);
        }
コード例 #22
0
        public void movementWithPack_packMoved_True()
        {
            var mockCharacter  = new Character();
            var mockAnchiornis = new Anchiornis();

            mockAnchiornis.IncreaseFriendliness(25);
            mockCharacter.AddToPack(mockAnchiornis);
            var mockTile = new MockTile(mockCharacter, 3, 3, 2, 2);

            mockTile.creatures = new List <ICreature>()
            {
                mockCharacter, mockAnchiornis
            };

            var  movement  = mockCharacter.Move(mockTile, ICreature.direction.N) as ITile;
            bool packMoved = movement.creatures.Contains(mockAnchiornis) ? true : false;

            Assert.True(packMoved);
        }
コード例 #23
0
        public void GetTile_ByPosition_ReturnsNewBoardWithUpdatedTile()
        {
            const int POSITION = 7;
            var       player   = new MockPlayer();
            var       newTile  = new MockTile().PositionReturns(POSITION).PlayerReturns(player);
            var       tile     = new MockTile().PositionReturns(POSITION).SetPlayerReturns(newTile);
            var       tiles    = new List <ITile> {
                new MockTile().PositionReturns(5),
                new MockTile().PositionReturns(2),
                tile
            };
            var boardService = new MockBoardService().GenerateTilesWithCoordinatesReturns(tiles);
            var board        = BuildBoard(boardService: boardService);

            var newBoard = board.ReserveTileBy(POSITION, player);

            Assert.NotEqual(board, newBoard);
            tile.VerifySetPlayerCalled(player);
        }
コード例 #24
0
        public void SetTile_ByCoordinate_ReturnsNewBoardWithUpdatedTile()
        {
            var player     = new MockPlayer();
            var coordinate = new MockCoordinate();
            var newTile    = new MockTile().PlayerReturns(player);
            var tile       = new MockTile().CoordinateReturns(coordinate).SetPlayerReturns(newTile);
            var tiles      = new List <ITile> {
                new MockTile().CoordinateReturns(new MockCoordinate()),
                new MockTile().CoordinateReturns(new MockCoordinate()),
                tile
            };
            var boardService = new MockBoardService().GenerateTilesWithCoordinatesReturns(tiles);
            var board        = BuildBoard(boardService: boardService);

            var newBoard = board.ReserveTileBy(coordinate, player);

            Assert.NotEqual(board, newBoard);
            tile.VerifySetPlayerCalled(player);
        }
コード例 #25
0
        public void ArchaeopteryxUs_SocialCoefficientIncreased_AnchiornisMoreAttractedThanOther()
        {
            var mockCharacter     = new Character();
            var mockArchaeopteryx = new Archaeopteryx();

            mockCharacter.CreditArchaeopteryx(mockArchaeopteryx);
            var mockFriendlyAnchiornis   = new Anchiornis();
            var mockUnfriendlyAnchiornis = new Anchiornis();

            mockFriendlyAnchiornis.IncreaseFriendliness(15);
            mockUnfriendlyAnchiornis.IncreaseFriendliness(15);
            var mockTile = new MockTile(mockCharacter, 3, 3, 2, 2);

            mockArchaeopteryx.OnUs(mockCharacter, mockFriendlyAnchiornis, mockTile);
            mockUnfriendlyAnchiornis.IncreaseFriendliness(mockCharacter.socialCoefficient);
            var friendlinessIsNotEqual = mockFriendlyAnchiornis.friendliness == mockUnfriendlyAnchiornis.friendliness;

            Assert.False(friendlinessIsNotEqual);
        }
コード例 #26
0
        public void OnlyPackMoved_CharacterOnNextTile_True()
        {
            var mockCharacter     = new Character();
            var mockAnchiornis    = new Anchiornis();
            var neutralAnchiornis = new Anchiornis();

            mockAnchiornis.IncreaseFriendliness(25);
            mockCharacter.AddToPack(mockAnchiornis);
            var mockTile = new MockTile(mockCharacter, 3, 3, 2, 2);

            mockTile.creatures = new List <ICreature>()
            {
                mockCharacter, mockAnchiornis, neutralAnchiornis
            };

            var  movement       = mockCharacter.Move(mockTile, ICreature.direction.NW) as ITile;
            bool characterMoved = movement.creatures.Contains(mockCharacter) ? true : false;

            Assert.True(characterMoved);
        }
コード例 #27
0
        public void GetTile_ByXY_ReturnsTile()
        {
            const int X          = 3;
            const int Y          = 2;
            var       coordinate = new MockCoordinate().XReturns(X).YReturns(Y);
            var       tile       = new MockTile().CoordinateReturns(coordinate);
            var       tiles      = new List <ITile> {
                new MockTile().CoordinateReturns(new MockCoordinate()),
                new MockTile().CoordinateReturns(new MockCoordinate()),
                tile
            };
            var boardService = new MockBoardService().GenerateTilesWithCoordinatesReturns(tiles);
            var board        = BuildBoard(boardService: boardService);

            var actual = board.GetTileBy(X, Y);

            Assert.Equal(tile, actual);
            tile.VerifyCoordinateCalled(2);
            coordinate.VerifyXCalled();
            coordinate.VerifyYCalled();
        }
コード例 #28
0
        public void PackMovingFromEnemy_enemyFailedPackMoved_False()
        {
            var mockCharacter   = new Character();
            var mockAnchiornis  = new Anchiornis();
            var enemyAnchiornis = new Anchiornis();

            mockAnchiornis.IncreaseFriendliness(25);
            mockCharacter.AddToPack(mockAnchiornis);
            var mockTile = new MockTile(mockCharacter, 3, 3, 2, 2);

            mockTile.creatures = new List <ICreature>()
            {
                mockCharacter, mockAnchiornis, enemyAnchiornis
            };

            var movement = mockCharacter.Move(mockTile, ICreature.direction.N) as ITile;

            enemyAnchiornis.Move(mockTile, movement, false);
            bool packMoved  = movement.creatures.Contains(mockAnchiornis) ? true : false;
            bool enemyMoved = movement.creatures.Contains(enemyAnchiornis) ? true : false;

            Assert.True(packMoved);
            Assert.False(enemyMoved);
        }