Beispiel #1
0
        public void AddPieceToLocation()
        {
            var chessBoard = new ChessBoard();

            var piece = new MockPiece();

            ILocation location = new MockLocation(3, 6);

            chessBoard.AddPiece(piece, location);

            var content = chessBoard.Board[location.y][location.x].BoardSquareContent;

            Assert.AreEqual(piece, content);
        }
Beispiel #2
0
        public void LocationConstructor_ILocation_Test()
        {
            ILocation iLoc = new MockLocation();

            iLoc.Latitude  = 89.22232;
            iLoc.Longitude = 22.44322;

            Location newLocation = new Location(iLoc);

            Assert.Equal(
                new { Lat = iLoc.Latitude, Long = iLoc.Longitude },
                new { Lat = newLocation.Latitude, Long = newLocation.Longitude }
                );
        }
Beispiel #3
0
        public void MovePieceTest()
        {
            //Setup board with MockPiece at a7/Board[1][0]
            var player = new MockPlayer();
            var board  = new ChessBoard();

            player.SetUpPieces(board);
            //Move MockPiece to b6/Board[2][1] (y=2, x=1)

            ILocation startLocation = new MockLocation(1, 0);
            ILocation endLocation   = new MockLocation(2, 1);

            board.MovePiece(startLocation, endLocation);

            Assert.IsNull(board.Board[1][0].BoardSquareContent);
            Assert.IsNotNull(board.Board[2][1].BoardSquareContent);
        }
Beispiel #4
0
        public void KingNotValidMoveTest()
        {
            var chessBoard = new ChessBoard();

            var piece = new MockKing();

            ILocation startLocation = new MockLocation(3, 6);

            chessBoard.AddPiece(piece, startLocation);

            ILocation endLocation = new MockLocation(0, 0);

            chessBoard.MovePiece(startLocation, endLocation);

            var content = chessBoard.Board[endLocation.y][endLocation.x].BoardSquareContent;

            Assert.AreNotEqual(piece, content);
        }
Beispiel #5
0
        public void UpdateChurch_Location_Tests(double lattitude, double longitude)
        {
            // If no churches in DbSet, add some
            if (!_churchService.AnyChurches())
            {
                AddSomeChurches();
            }

            var actualListBefore = (List <Church>)_churchService.ReturnAllChurchesForTesting();
            var churchToUpdate   = actualListBefore.Find(c => c is IChurch);
            var updatedLoc       = new MockLocation {
                Latitude = lattitude, Longitude = longitude
            };

            churchToUpdate.Coordinates = updatedLoc;

            _churchService.UpdateChurch(churchToUpdate.Id, churchToUpdate);

            var actualListAfter = (List <Church>)_churchService.ReturnAllChurchesForTesting();
            var actual          = actualListAfter.Find(c => c.Id == churchToUpdate.Id);

            Assert.Equal(churchToUpdate.Coordinates, actual.Coordinates);
        }