Esempio n. 1
0
        public async void RestaurantCache_GetRestaurantListAsync_ReturnsListIfPresent()
        {
            // arrange
            string               zip         = "38655";
            Mock <ICache>        cache       = new Mock <ICache>();
            List <RestaurantDto> restaurants = new List <RestaurantDto> {
                new RestaurantDto {
                    Name = "bob's burgers",
                    Id   = "bob"
                },
                new RestaurantDto {
                    Name = "Tim's tacos",
                    Id   = "tim"
                }
            };

            cache.Setup(x => x.GetAsync <List <RestaurantDto> >(zip)).ReturnsAsync(restaurants);

            var target = new RestaurantCacheBuilder()
                         .SetCache(cache.Object)
                         .Build();

            // act
            var result = await target.GetRestaurantListAsync(zip);

            // assert
            Assert.Equal(restaurants, result);
        }
Esempio n. 2
0
        public async void RestaurantCache_GetRestaurantListAsync_ReturnsNullIfNotPresent()
        {
            // arrange
            string zip = "90210";

            var target = new RestaurantCacheBuilder()
                         .Build();

            // act
            var result = await target.GetRestaurantListAsync(zip);

            // assert
            Assert.Null(result);
        }