Ejemplo n.º 1
0
        public async Task <RestaurantResults> Get(string outcode)
        {
            if (string.IsNullOrEmpty(outcode))
            {
                return(new RestaurantResults());
            }

            return(await _queryRestaurants.GetAsync(outcode));
        }
Ejemplo n.º 2
0
        public async Task GetsRestaurants_ByOutcode()
        {
            const string outcode     = "outcode";
            var          apiUrl      = $"{_mockWebConfig.Object.RestaurantsApiUrl}{outcode}";
            var          restaurants = Builder <Restaurant> .CreateListOfSize(3).Build().ToList();

            _mockJsonConverter.Setup(x => x.Deserialize <IEnumerable <Restaurant> >(It.IsAny <string>()))
            .Returns(new List <Restaurant>());
            _mockHttpClient.Setup(x => x.GetAsync(apiUrl, It.IsAny <KeyValuePair <string, string>[]>()))
            .ReturnsAsync(new HttpResponseMessage
            {
                Content = new StringContent(SerializeObject(restaurants))
            }).Verifiable();

            await _restaurantsManager.GetAsync(outcode);

            _mockHttpClient.Verify();
        }