public EventController(YelpService yelp, ApplicationDbContext db, GoogleService google, UserManager <IdentityUser> userManager)
 {
     _yelp        = yelp;
     _db          = db;
     _google      = google;
     _userManager = userManager;
 }
Ejemplo n.º 2
0
        public async void YelpService_GetAvailableRestaurantOptionsAsync_ReturnsTotalNumberOfAvailableResults()
        {
            // arrange
            int total = 0;
            RestaurantCacheMock mockCache = new RestaurantCacheMock();
            YelpService         target    = new YelpService(_apiKey, mockCache);

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + _apiKey);
                HttpResponseMessage message = await client.GetAsync("https://api.yelp.com/v3/businesses/search?categories=restaurants,!hotdogs&location=38655&radius=20000&limit=50&sort_by=best_match");

                dynamic dto = JsonConvert.DeserializeObject <dynamic>(await message.Content.ReadAsStringAsync().ConfigureAwait(false));
                total = dto.total;
            }

            // act
            DateTime startTime = DateTime.UtcNow;
            IEnumerable <RestaurantDto> result = await target.GetAvailableRestaurantOptionsAsync(Guid.Empty, new SearchOptions { Meal = MealTime.all });

            DateTime endTime    = DateTime.UtcNow;
            TimeSpan firstWatch = endTime - startTime;

            startTime = DateTime.UtcNow;
            await target.GetAvailableRestaurantOptionsAsync(Guid.Empty, new SearchOptions { Meal = MealTime.all });

            endTime = DateTime.UtcNow;
            TimeSpan secondWatch = endTime - startTime;


            // assert
            Assert.Equal(total, result.Count());
            Assert.True(firstWatch.TotalMilliseconds > 1000);
            Assert.True(secondWatch.TotalMilliseconds < 200);
        }
Ejemplo n.º 3
0
 public HomeController(ILogger <HomeController> logger, YelpService yelp, ApplicationDbContext db, ApplicationDbContext context, UserManager <IdentityUser> userManager)
 {
     _logger      = logger;
     _yelp        = yelp;
     _db          = db;
     _context     = context;
     _userManager = userManager;
 }
Ejemplo n.º 4
0
        public async void YelpService_GetAvailableRestaurantOptionsAsync_ReturnsDifferentRestaurantsWhenGivenDifferentLocations()
        {
            // arrange
            RestaurantCacheMock mockCache = new RestaurantCacheMock();
            YelpService         target    = new YelpService(_apiKey, new Mock <IRestaurantCache>().Object);

            // act
            IEnumerable <RestaurantDto> result = await target.GetAvailableRestaurantOptionsAsync(Guid.Empty, new SearchOptions { Zip = "38655" });

            IEnumerable <RestaurantDto> result2 = await target.GetAvailableRestaurantOptionsAsync(Guid.Empty, new SearchOptions { Zip = "38834" });

            // assert
            Assert.NotEqual(result, result2);
        }
Ejemplo n.º 5
0
        public async void YelpService_GetAvailableRestaurantOptionsAsync_ReturnsFewerResultsWhenSpecifyingMeal()
        {
            // arrange
            RestaurantCacheMock mockCache = new RestaurantCacheMock();
            YelpService         target    = new YelpService(_apiKey, new Mock <IRestaurantCache>().Object);

            // act
            IEnumerable <RestaurantDto> result = await target.GetAvailableRestaurantOptionsAsync(Guid.Empty, new SearchOptions { Meal = MealTime.all });

            IEnumerable <RestaurantDto> result2 = await target.GetAvailableRestaurantOptionsAsync(Guid.Empty, new SearchOptions { Meal = MealTime.breakfast });

            // assert
            Assert.True(result.Count() > result2.Count());
        }
Ejemplo n.º 6
0
 public SettingsController()
 {
     _settingsService = new SettingsService();
     _yelpService     = new YelpService();
 }
Ejemplo n.º 7
0
 private YelpController()
 {
     _yelpService = new YelpService();
 }