public void SetupCalculatorTrolleyApiResult(TrolleyInfo trolleyInfo, decimal calculatedTotal) { var responseHttpContent = JsonConvert.SerializeObject(calculatedTotal); var apiUrl = "http://apihost/api/resource/trolleycalulator"; var token = "TestToken"; MockSerializer .Setup(o => o.Serialize(trolleyInfo)) .Returns <TrolleyInfo>(t => JsonConvert.SerializeObject(t)); MockExternalApiPathProvider .Setup(o => o.GetApiPath(ExternalApiPathName.CalculateTrolley)) .Returns(apiUrl); MockConfigProvider .Setup(o => o.GetConfigValue(ConfigKeys.Token)) .Returns(token); var apiRequestUrl = $"{apiUrl}?token={token}"; var jsonMimeType = "application/json"; MockMessageHandler .When(HttpMethod.Post, apiRequestUrl) .WithContent(JsonConvert.SerializeObject(trolleyInfo)) .WithHeaders("Content-Type", jsonMimeType) .Respond(jsonMimeType, responseHttpContent); }
public void SetupGetGetShopperHistoryApiResult(List <ShopperHistory> shopperHistoryList) { var httpContent = JsonConvert.SerializeObject(shopperHistoryList); var apiUrl = "http://apihost/api/resource/shopperhistory"; var token = "TestToken"; MockSerializer .Setup(o => o.Deserialize <List <ShopperHistory> >(It.IsAny <string>())) .Returns <string>(s => JsonConvert.DeserializeObject <List <ShopperHistory> >(s)); MockExternalApiPathProvider .Setup(o => o.GetApiPath(ExternalApiPathName.GetShopperHistory)) .Returns(apiUrl); MockConfigProvider .Setup(o => o.GetConfigValue(ConfigKeys.Token)) .Returns(token); var apiRequestUrl = $"{apiUrl}?token={token}"; MockMessageHandler .When(HttpMethod.Get, apiRequestUrl) .Respond("application/json", httpContent); }