Ejemplo n.º 1
0
        public void WriteSetCacheTest()
        {
            var statsLogged = false;

            MyCachingProvider provider = new MyCachingProvider();

            FakeDiagnosticListenerObserver diagnosticListenerObserver = new FakeDiagnosticListenerObserver(kvp =>
            {
                if (kvp.Key.Equals("EasyCaching.WriteSetCacheBefore"))
                {
                    Assert.NotNull(kvp.Value);

                    statsLogged = true;
                }
            });

            diagnosticListenerObserver.Enable();
            using (DiagnosticListener.AllListeners.Subscribe(diagnosticListenerObserver))
            {
                var cacheKey = "WriteSetCache-key";

                provider.Set(cacheKey, "aa", TimeSpan.FromSeconds(10));

                Assert.True(statsLogged);

                diagnosticListenerObserver.Disable();
            }
        }
Ejemplo n.º 2
0
        public void WriteFlushCacheTest()
        {
            var statsLogged = false;

            MyCachingProvider provider = new MyCachingProvider();

            FakeDiagnosticListenerObserver diagnosticListenerObserver = new FakeDiagnosticListenerObserver(kvp =>
            {
                if (kvp.Key.Equals("EasyCaching.WriteFlushCacheBefore"))
                {
                    Assert.NotNull(kvp.Value);

                    statsLogged = true;
                }
            });

            diagnosticListenerObserver.Enable();
            using (DiagnosticListener.AllListeners.Subscribe(diagnosticListenerObserver))
            {
                provider.Flush();

                Assert.True(statsLogged);

                diagnosticListenerObserver.Disable();
            }
        }
Ejemplo n.º 3
0
        public void WriteExistsCacheTest()
        {
            var statsLogged = false;

            MyCachingProvider provider = new MyCachingProvider();

            FakeDiagnosticListenerObserver diagnosticListenerObserver = new FakeDiagnosticListenerObserver(kvp =>
            {
                if (kvp.Key.Equals("EasyCaching.WriteExistsCacheBefore"))
                {
                    Assert.NotNull(kvp.Value);

                    statsLogged = true;
                }
                else if (kvp.Key.Equals("EasyCaching.WriteExistsCacheAfter"))
                {
                    Assert.NotNull(kvp.Value);

                    statsLogged = true;
                }
            });

            diagnosticListenerObserver.Enable();
            using (DiagnosticListener.AllListeners.Subscribe(diagnosticListenerObserver))
            {
                var cacheKey = "WriteExistsCache-key";

                var res = provider.Exists(cacheKey);

                Assert.True(statsLogged);

                diagnosticListenerObserver.Disable();
            }
        }