public void Bug3191956()
        {
            var queue = new Queue <iCalDateTime>();

            for (int i = 0; i < 4; i++)
            {
                var dateTime = new iCalDateTime(2011, 1, 1);
                dateTime.HasTime = false;
                queue.Enqueue(dateTime);
            }

            IDateTime dt = queue.Dequeue();

            Assert.IsFalse(dt.HasTime);
            dt = dt.AddHours(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddHours(24);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddHours(1);
            Assert.IsTrue(dt.HasTime);

            dt = queue.Dequeue();
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMinutes(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMinutes(1440);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMinutes(1);
            Assert.IsTrue(dt.HasTime);

            dt = queue.Dequeue();
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddSeconds(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddSeconds(86400);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddSeconds(1);
            Assert.IsTrue(dt.HasTime);

            dt = queue.Dequeue();
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMilliseconds(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMilliseconds(86400000);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMilliseconds(1);
            Assert.IsTrue(dt.HasTime);
        }
示例#2
0
        public async Task <JsonResult> SearchProduct(string detail)
        {
            List <ModelForProductsList> products = new List <ModelForProductsList>();

            if (!cache.TryGetValue <List <ModelForProductsList> >(detail, out products))
            {
                products = await Task.Run(() => repository.SearchProduct(detail).ToList());

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions();
                options.AbsoluteExpiration = clock.AddMinutes(3);
                options.SlidingExpiration  = clock.FromMinutes(3);
                cache.Set <List <ModelForProductsList> >(detail, products, options);
            }

            return(Json(products));
        }