public async Task GetAccountInfoForEveryPlayer() { var httpClient = new Mock <IHttpClient>(); var jsonSerializer = new Mock <IJsonSerializer>(); var players = new List <HeroesPlayersDto> { new HeroesPlayersDto { AccountId = "2" }, new HeroesPlayersDto { AccountId = "3" }, new HeroesPlayersDto { AccountId = "5" } }; var playerProfile = new PlayerProfileDetailsDto(); var mapper = new Mock <IMapper>(); mapper.Setup(x => x.Map <IEnumerable <HeroesPlayersDto> >(It.IsAny <object>())).Returns(players); mapper.Setup(x => x.Map <PlayerProfileDetailsDto>(It.IsAny <object>())).Returns(playerProfile); var heroesProvider = new Mock <IHeroesProvider>(); var itemsProvider = new Mock <IItemsProvider>(); var playerService = new PlayerService(httpClient.Object, jsonSerializer.Object, mapper.Object, heroesProvider.Object, itemsProvider.Object); var accountUrl1 = string.Format(DotaApiEndpoints.PlayerDetailsUrlTemplate, "2"); var accountUrl2 = string.Format(DotaApiEndpoints.PlayerDetailsUrlTemplate, "3"); var accountUrl3 = string.Format(DotaApiEndpoints.PlayerDetailsUrlTemplate, "5"); await playerService.GetHeroDetailsAsync(Id); httpClient.Verify(x => x.GetAsync(accountUrl1, null), Times.Once); httpClient.Verify(x => x.GetAsync(accountUrl2, null), Times.Once); httpClient.Verify(x => x.GetAsync(accountUrl3, null), Times.Once); }
public async Task ReturnProperData() { var heroes = new List <PlayerHeroesDto>(); var recentMatches = new List <PlayerRecentMatchesDto>(); var playerProfile = new PlayerProfileDetailsDto(); var playerWinsAndLosses = new PlayerWinsLossesDto(); var httpClient = new Mock <IHttpClient>(); var jsonSerializer = new Mock <IJsonSerializer>(); var mapper = new Mock <IMapper>(); mapper.Setup(x => x.Map <ICollection <PlayerHeroesDto> >(It.IsAny <object>())).Returns(() => heroes); mapper.Setup(x => x.Map <ICollection <PlayerRecentMatchesDto> >(It.IsAny <object>())).Returns(() => recentMatches); mapper.Setup(x => x.Map <PlayerProfileDetailsDto>(It.IsAny <object>())).Returns(() => playerProfile); mapper.Setup(x => x.Map <PlayerWinsLossesDto>(It.IsAny <object>())).Returns(() => playerWinsAndLosses); var heroesProvider = new Mock <IHeroesProvider>(); var itemsProvider = new Mock <IItemsProvider>(); var playerService = new PlayerService(httpClient.Object, jsonSerializer.Object, mapper.Object, heroesProvider.Object, itemsProvider.Object); var result = await playerService.GetPlayerDetailsAsync("id"); Assert.AreEqual(heroes, result.Heroes); Assert.AreEqual(recentMatches, result.RecentMatchHistory); Assert.AreEqual(playerWinsAndLosses, result.WinsAndLosses); Assert.AreEqual(playerProfile, result.Details); }