示例#1
0
 public void LookupIsCached()
 {
     var inputCode = Guid.NewGuid().ToString();
     var lookup = new StatusCodeMap();
     var outputCode = lookup.GetStatusCode(inputCode);
     var stopwatch = Stopwatch.StartNew();
     var outputCode2 = lookup.GetStatusCode(inputCode);
     Assert.IsTrue(stopwatch.ElapsedMilliseconds < LookupMilliseconds);
 }
        public void LookupIsCached()
        {
            var inputCode   = Guid.NewGuid().ToString();
            var lookup      = new StatusCodeMap();
            var outputCode  = lookup.GetStatusCode(inputCode);
            var stopwatch   = Stopwatch.StartNew();
            var outputCode2 = lookup.GetStatusCode(inputCode);

            Assert.IsTrue(stopwatch.ElapsedMilliseconds < LookupMilliseconds);
        }
示例#3
0
 public void CacheExpires()
 {
     var inputCode = Guid.NewGuid().ToString();
     var lookup = new StatusCodeMap();
     var outputCode = lookup.GetStatusCode(inputCode);
     Thread.Sleep(CacheLifespanMilliseconds);
     var stopwatch = Stopwatch.StartNew();
     var outputCode2 = lookup.GetStatusCode(inputCode);
     Thread.Sleep(1);
     Assert.IsTrue(stopwatch.ElapsedMilliseconds > LookupMilliseconds);
 }
        public void CacheExpires()
        {
            var inputCode  = Guid.NewGuid().ToString();
            var lookup     = new StatusCodeMap();
            var outputCode = lookup.GetStatusCode(inputCode);

            Thread.Sleep(CacheLifespanMilliseconds);
            var stopwatch   = Stopwatch.StartNew();
            var outputCode2 = lookup.GetStatusCode(inputCode);

            Thread.Sleep(1);
            Assert.IsTrue(stopwatch.ElapsedMilliseconds > LookupMilliseconds);
        }
示例#5
0
 public void DifferentInstancesShareCache()
 {
     var inputCode = Guid.NewGuid().ToString();
     var lookup1 = new StatusCodeMap();
     var outputCode = lookup1.GetStatusCode(inputCode);
     var lookup2 = new StatusCodeMap();
     var stopwatch = Stopwatch.StartNew();
     var outputCode2 = lookup2.GetStatusCode(inputCode);
     Assert.IsTrue(stopwatch.ElapsedMilliseconds < CacheLifespanMilliseconds);
 }
        public void DifferentInstancesShareCache()
        {
            var inputCode   = Guid.NewGuid().ToString();
            var lookup1     = new StatusCodeMap();
            var outputCode  = lookup1.GetStatusCode(inputCode);
            var lookup2     = new StatusCodeMap();
            var stopwatch   = Stopwatch.StartNew();
            var outputCode2 = lookup2.GetStatusCode(inputCode);

            Assert.IsTrue(stopwatch.ElapsedMilliseconds < CacheLifespanMilliseconds);
        }