Ejemplo n.º 1
0
 public void WillCallBackAtSetInterval()
 {
     ExpirationPollTimer timer = new ExpirationPollTimer();
     timer.StartPolling(new TimerCallback(CallbackMethod), 100);
     Thread.Sleep(1100);
     timer.StopPolling();
     Assert.IsTrue((counter >= 9) && (counter <= 12));
 }
Ejemplo n.º 2
0
        public void WillCallBackAtSetInterval()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer();

            timer.StartPolling(new TimerCallback(CallbackMethod), 100);
            Thread.Sleep(1100);
            timer.StopPolling();
            Assert.IsTrue((counter >= 9) && (counter <= 12));
        }
Ejemplo n.º 3
0
        public void CanStopPolling()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer(100);

            timer.StartPolling(new TimerCallback(CallbackMethod));
            Thread.Sleep(1100);
            timer.StopPolling();
            Thread.Sleep(250);
            Assert.IsTrue((counter >= 9) && (counter <= 12));
        }
Ejemplo n.º 4
0
        public CacheManager BuildCacheManager(
            string cacheManagerName,
            IBackingStore backingStore,
            int maximumElementsInCacheBeforeScavenging,
            int numberToRemoveWhenScavenging,
            int expirationPollFrequencyInSeconds,
            CachingInstrumentationProvider instrumentationProvider)
        {
            CacheCapacityScavengingPolicy scavengingPolicy =
                new CacheCapacityScavengingPolicy(maximumElementsInCacheBeforeScavenging);
            Cache cache = new Cache(backingStore, scavengingPolicy, instrumentationProvider);
            ExpirationPollTimer timer          = new ExpirationPollTimer();
            ExpirationTask      expirationTask = CreateExpirationTask(cache, instrumentationProvider);
            ScavengerTask       scavengerTask  = new ScavengerTask(numberToRemoveWhenScavenging, scavengingPolicy, cache, instrumentationProvider);
            BackgroundScheduler scheduler      = new BackgroundScheduler(expirationTask, scavengerTask, instrumentationProvider);

            cache.Initialize(scheduler);
            scheduler.Start();
            timer.StartPolling(new TimerCallback(scheduler.ExpirationTimeoutExpired), expirationPollFrequencyInSeconds * 1000);
            return(new CacheManager(cache, scheduler, timer));
        }
Ejemplo n.º 5
0
 public void StartingWithZeroPollTimeThrowsException()
 {
     ExpirationPollTimer timer = new ExpirationPollTimer();
     timer.StartPolling(new TimerCallback(CallbackMethod), 0);
 }
Ejemplo n.º 6
0
 public void StartingWithNullCallbackThrowsException()
 {
     ExpirationPollTimer timer = new ExpirationPollTimer();
     timer.StartPolling(null, 100);
 }
Ejemplo n.º 7
0
        public void StartingWithZeroPollTimeThrowsException()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer();

            timer.StartPolling(new TimerCallback(CallbackMethod), 0);
        }
Ejemplo n.º 8
0
        public void StartingWithNullCallbackThrowsException()
        {
            ExpirationPollTimer timer = new ExpirationPollTimer();

            timer.StartPolling(null, 100);
        }