예제 #1
0
        public async Task GetPlayersTest()
        {
            var movies = new List <Player>
            {
                new Player()
                {
                    PlayerName = "test messi1"
                },
                new Player()
                {
                    PlayerName = "test messi2"
                }
            };

            var fakeRepositoryMock = new Mock <IPlayerRepository>();

            fakeRepositoryMock.Setup(x => x.GetAll()).ReturnsAsync(movies);


            var playerService = new PlayerServices(fakeRepositoryMock.Object);

            var resultPlayers = await playerService.GetPlayers();

            Assert.Collection(resultPlayers, player =>
            {
                Assert.Equal("test messi1", player.PlayerName);
            },
                              player =>
            {
                Assert.Equal("test messi2", player.PlayerName);
            });
        }
예제 #2
0
        public ActionResult <Dictionary <int, Player> > GetPlayers()
        {
            var players = _services.GetPlayers();

            if (players.Count == 0)
            {
                return(NotFound());
            }

            return(players);
        }