Ejemplo n.º 1
0
 /// <summary>
 /// Make sure we can at least store profiler results to the http runtime cache.
 /// </summary>
 internal static void EnsureStorageStrategy()
 {
     if (Storage == null)
     {
         Storage = new HttpRuntimeCacheStorage(TimeSpan.FromDays(1));
     }
 }
Ejemplo n.º 2
0
        public void TestRangeQueries()
        {
            var now = DateTime.UtcNow;
            var inASec = now.AddSeconds(1);
            var in2Secs = now.AddSeconds(2);
            var in3Secs = now.AddSeconds(3);
            var profiler = new MiniProfiler("/") { Started = now, Id = Guid.NewGuid() };
            var profiler1 = new MiniProfiler("/") { Started = inASec, Id = Guid.NewGuid() };
            var profiler2 = new MiniProfiler("/") { Started = in2Secs, Id = Guid.NewGuid() };
            var profiler3 = new MiniProfiler("/") { Started = in3Secs, Id = Guid.NewGuid() };
            
            var storage = new HttpRuntimeCacheStorage(new TimeSpan(1, 0, 0));

            storage.Save(profiler);
            storage.Save(profiler3);
            storage.Save(profiler2);
            storage.Save(profiler1);

            var guids = storage.List(100);
            Assert.AreEqual(4, guids.Count());

            guids = storage.List(1);
            Assert.AreEqual(1, guids.Count());

            guids = storage.List(2, now, in2Secs);
            Assert.AreEqual(profiler2.Id, guids.First());
            Assert.AreEqual(profiler1.Id, guids.Skip(1).First());
            Assert.AreEqual(2, guids.Count());
        }
Ejemplo n.º 3
0
 public void TestWeCanSaveTheSameProfilerTwice()
 {
     var profiler = new MiniProfiler("/") { Started = DateTime.UtcNow, Id = Guid.NewGuid() };
     var storage = new HttpRuntimeCacheStorage(new TimeSpan(1, 0, 0));
     storage.Save(profiler);
     storage.Save(profiler);
     var guids = storage.List(100).ToArray();
     Assert.AreEqual(profiler.Id, guids.First());
     Assert.AreEqual(1, guids.Count());
 }
Ejemplo n.º 4
0
        public void TestWeCanSaveTheSameProfilerTwice()
        {
            var profiler = new MiniProfiler {
                Started = DateTime.UtcNow, Id = Guid.NewGuid()
            };
            var storage = new HttpRuntimeCacheStorage(new TimeSpan(1, 0, 0));

            storage.Save(profiler);
            storage.Save(profiler);
            var guids = storage.List(100).ToArray();

            Assert.AreEqual(profiler.Id, guids.First());
            Assert.AreEqual(1, guids.Count());
        }
Ejemplo n.º 5
0
 public static void EnsureTesterProvider()
 {
     if (TesterProvider == null)
     {
         // Set the default yo...
         TesterProvider = new WebRequestTesterProvider();
     }
     if (Storage == null)
     {
         //default
         Storage = new HttpRuntimeCacheStorage(TimeSpan.FromDays(1));
     }
     if (UserProvider == null)
     {
         //default
         UserProvider = new IpAddressIdentity();
     }
 }
Ejemplo n.º 6
0
        public void TestRangeQueries()
        {
            var now      = DateTime.UtcNow;
            var inASec   = now.AddSeconds(1);
            var in2Secs  = now.AddSeconds(2);
            var in3Secs  = now.AddSeconds(3);
            var profiler = new MiniProfiler("/")
            {
                Started = now, Id = Guid.NewGuid()
            };
            var profiler1 = new MiniProfiler("/")
            {
                Started = inASec, Id = Guid.NewGuid()
            };
            var profiler2 = new MiniProfiler("/")
            {
                Started = in2Secs, Id = Guid.NewGuid()
            };
            var profiler3 = new MiniProfiler("/")
            {
                Started = in3Secs, Id = Guid.NewGuid()
            };

            var storage = new HttpRuntimeCacheStorage(new TimeSpan(1, 0, 0));

            storage.Save(profiler);
            storage.Save(profiler3);
            storage.Save(profiler2);
            storage.Save(profiler1);

            var guids = storage.List(100);

            Assert.AreEqual(4, guids.Count());

            guids = storage.List(1);
            Assert.AreEqual(1, guids.Count());

            guids = storage.List(2, now, in2Secs);
            Assert.AreEqual(profiler2.Id, guids.First());
            Assert.AreEqual(profiler1.Id, guids.Skip(1).First());
            Assert.AreEqual(2, guids.Count());
        }