/// <summary>
        /// Check single callback event.
        /// </summary>
        /// <param name="expKey">Expected key.</param>
        /// <param name="expOldVal">Expected old value.</param>
        /// <param name="expVal">Expected new value.</param>
        /// <param name="expType">Expected type.</param>
        /// <param name="timeout">Timeout.</param>
        private static void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal,
                                                CacheEntryEventType expType, int timeout = 1000)
        {
            CallbackEvent evt;

            Assert.IsTrue(CB_EVTS.TryTake(out evt, timeout));
            Assert.AreEqual(0, CB_EVTS.Count);

            var e = evt.entries.Single();

            Assert.AreEqual(expKey, e.Key);
            Assert.AreEqual(expOldVal, e.OldValue);
            Assert.AreEqual(expVal, e.Value);
            Assert.AreEqual(expType, e.EventType);
        }
Exemplo n.º 2
0
        public void OnEvent_AcceptedEvent(CacheEntryEventType evtType, bool expectedToBeAccepted)
        {
            var mockEvent = new Mock <ICacheEntryEvent <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> >();

            mockEvent.Setup(x => x.EventType).Returns(evtType);

            using (var handler = new SiteModelChangeProcessorItemHandler())
            {
                var listener = new LocalSiteModelChangeListener(handler);
                listener.OnEvent(new List <ICacheEntryEvent <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> > {
                    mockEvent.Object
                });

                // the listener should have placed the event in to the handler
                handler.QueueCount.Should().Be(expectedToBeAccepted ? 1 : 0);
            }
        }