Ejemplo n.º 1
0
        public async void RestaurantCache_AddSeenOptionAsync_CallsCacheSetWhenCacheIsNonEmpty()
        {
            // arrange
            Guid          sessionId      = Guid.NewGuid();
            string        option         = "The Restaurant at the End of the Universe";
            const string  existingOption = "Restaurant over there";
            List <string> list           = new List <string>
            {
                existingOption
            };

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

            cache.Setup(x => x.GetAsync <List <string> >(It.IsAny <String>())).ReturnsAsync(list);

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

            // act
            await target.AddSeenOptionAsync(sessionId, option);

            // assert
            cache.Verify(c => c.SetAsync <List <string> >($"{sessionId.ToString()}_seenoptions", It.Is <List <string> >(x => x.Contains(option) && x.Contains(existingOption) && x.Count == 2), null), Times.Once);
        }
Ejemplo n.º 2
0
        public async void RestaurantCache_AddSeenOptionAsync_CallsCacheSetWithSIngleOption()
        {
            // // arrange
            Guid   sessionId = Guid.NewGuid();
            string option    = "The Restaurant at the End of the Universe";

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

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

            // // act
            await target.AddSeenOptionAsync(sessionId, option);

            // assert
            cache.Verify(c => c.SetAsync <List <string> >($"{sessionId.ToString()}_seenoptions", It.Is <List <string> >(x => x.Contains(option)), null), Times.Once);
        }