Esempio n. 1
0
        public async void RestaurantCache_GetSeenOptions_ReturnsEmptyListWhenNotCached()
        {
            // // arrange
            Guid sessionId = Guid.NewGuid();

            Mock <ICache> cache = new Mock <ICache>();

            cache.Setup(x => x.GetAsync <List <string> >($"{sessionId.ToString()}_seenoptions")).ReturnsAsync(default(List <string>));
            var target = new RestaurantCacheBuilder()
                         .SetCache(cache.Object)
                         .Build();

            // // act
            var result = await target.GetSeenOptionsAsync(sessionId);

            // // assert
            Assert.Equal(new List <string>(), result);
        }
Esempio n. 2
0
        public async void RestaurantCache_GetSeenOptions_ReturnsOptionsWhenCached()
        {
            // // arrange
            Guid          sessionId = Guid.NewGuid();
            Mock <ICache> cache     = new Mock <ICache>();
            List <string> options   = new List <string> {
                "bob",
                "john",
                "tim",
            };

            cache.Setup(x => x.GetAsync <List <string> >($"{sessionId.ToString()}_seenoptions")).ReturnsAsync(options);

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

            // // act
            var result = await target.GetSeenOptionsAsync(sessionId);

            // // assert
            Assert.Equal(options, result);
        }