public GetTanksInfoOperation( IWargamingTanksApiClient wargamingApi, IMapper mapper, ILogger <GetTanksInfoOperation> logger) { _wargamingApi = wargamingApi; _mapper = mapper; _logger = logger; }
protected void InitWgApiClient() { var settingsMock = new Mock <IWargamingApiSettings>(); settingsMock.SetupGet(s => s.ApplicationId).Returns(ApplicationId); var playerInfoFilePath = GetFixturePath("PlayerInfo50.json"); var tanksInfoFilePath = GetFixturePath("TanksInfo50.json"); var playerAchievementsFilePath = GetFixturePath("PlayerAchievements50.json"); var tanksAchievementsFilePath = GetFixturePath("TanksAchievemnts50.json"); var playerInfoRequestUrl = $"https://api.wotblitz.eu/wotb/account/info/?application_id={ApplicationId}&language=en&account_id={AccountId}"; var playerInfoResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(File.ReadAllText(playerInfoFilePath)), }; var tanksInfoRequestUrl = $"https://api.wotblitz.eu/wotb/tanks/stats/?application_id={ApplicationId}&language=en&account_id={AccountId}"; var tanksInfoResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(File.ReadAllText(tanksInfoFilePath)), }; var handlerMock = new Mock <HttpMessageHandler>(); handlerMock .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.Is <HttpRequestMessage>(m => m.RequestUri.ToString() == playerInfoRequestUrl), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(playerInfoResponse); handlerMock .Protected() .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.Is <HttpRequestMessage>(m => m.RequestUri.ToString() == tanksInfoRequestUrl), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(tanksInfoResponse); var client = new WargamingApiClient(new HttpClient(handlerMock.Object), settingsMock.Object); WargamingApiClient = client; WargamingTanksApiClient = client; }