Esempio n. 1
0
 public void UnusedSignalCanBeFiredSafely()
 {
     var signal = new CacheSignal();
     signal.FireChanged();
     signal.Changed += ignore_signal_event_handler;
     signal.FireChanged();
     signal.Changed -= ignore_signal_event_handler;
     signal.FireChanged();
 }
Esempio n. 2
0
        public void UnusedSignalCanBeFiredSafely()
        {
            var signal = new CacheSignal();

            signal.FireChanged();
            signal.Changed += ignore_signal_event_handler;
            signal.FireChanged();
            signal.Changed -= ignore_signal_event_handler;
            signal.FireChanged();
        }
Esempio n. 3
0
        public void SignalCanBeFiredExternally()
        {
            var fired = false;
            var signal = new CacheSignal();
            signal.Changed += (sender, e) => { fired = true; };

            Assert.That(fired, Is.False);
            signal.FireChanged();
            Assert.That(fired, Is.True);
        }
Esempio n. 4
0
        public void SignalCanBeFiredExternally()
        {
            var fired  = false;
            var signal = new CacheSignal();

            signal.Changed += (sender, e) => { fired = true; };

            Assert.That(fired, Is.False);
            signal.FireChanged();
            Assert.That(fired, Is.True);
        }
Esempio n. 5
0
        public void SignalWillExpireOutputCachingEntry()
        {
            _viewFolder.Add("home\\index.spark", @"
<viewdata model=""System.Func<string>"" datasignal='Spark.ICacheSignal'/>
<div>
<cache key='string.Empty' signal='datasignal'>
<p>${ViewData.Model()}</p>
</cache>
</div>");
            var signal = new CacheSignal();
            var calls  = 0;
            var data   = new StubViewData <Func <string> >
            {
                Model = () => (++calls).ToString()
            };

            data["datasignal"] = signal;

            var contents = Render("index", data);

            Assert.That(contents, Is.EqualTo(@"
<div>
<p>1</p>
</div>"));
            Assert.That(calls, Is.EqualTo(1));

            contents = Render("index", data);
            Assert.That(contents, Is.EqualTo(@"
<div>
<p>1</p>
</div>"));
            Assert.That(calls, Is.EqualTo(1));

            signal.FireChanged();

            contents = Render("index", data);
            Assert.That(contents, Is.EqualTo(@"
<div>
<p>2</p>
</div>"));
            Assert.That(calls, Is.EqualTo(2));

            contents = Render("index", data);
            Assert.That(contents, Is.EqualTo(@"
<div>
<p>2</p>
</div>"));
            Assert.That(calls, Is.EqualTo(2));
        }
        public void A_CacheTypeNoneの送受信()
        {
            var mock = Substitute.For <IObserver <CacheSignal> >();

            ReceiverForCacheNone.Receive().Subscribe(mock.OnNext);

            PublisherForCacheNone.Publish(CacheSignal.Create(1));
            PublisherForCacheNone.Publish(CacheSignal.Create(2));

            mock.Received(2).OnNext(Arg.Any <CacheSignal>());

            mock.ClearReceivedCalls();

            ReceiverForCacheNone.Receive().Subscribe(mock.OnNext);

            mock.DidNotReceive().OnNext(Arg.Any <CacheSignal>());
        }
Esempio n. 7
0
 public CacheWorker(
     ILogger <CacheWorker> logger,
     HttpClient httpClient,
     CacheSignal <Photo> cacheSignal,
     IMemoryCache cache) =>
 (_logger, _httpClient, _cacheSignal, _cache) = (logger, httpClient, cacheSignal, cache);
Esempio n. 8
0
        public void SignalWillExpireOutputCachingEntry()
        {
            _viewFolder.Add("home\\index.spark", @"
            <viewdata model=""System.Func<string>"" datasignal='Spark.ICacheSignal'/>
            <div>
            <cache key='string.Empty' signal='datasignal'>
            <p>${ViewData.Model()}</p>
            </cache>
            </div>");
            var signal = new CacheSignal();
            var calls = 0;
            var data = new StubViewData<Func<string>>
            {
                Model = () => (++calls).ToString()
            };
            data["datasignal"] = signal;

            var contents = Render("index", data);
            Assert.That(contents, Is.EqualTo(@"
            <div>
            <p>1</p>
            </div>"));
            Assert.That(calls, Is.EqualTo(1));

            contents = Render("index", data);
            Assert.That(contents, Is.EqualTo(@"
            <div>
            <p>1</p>
            </div>"));
            Assert.That(calls, Is.EqualTo(1));

            signal.FireChanged();

            contents = Render("index", data);
            Assert.That(contents, Is.EqualTo(@"
            <div>
            <p>2</p>
            </div>"));
            Assert.That(calls, Is.EqualTo(2));

            contents = Render("index", data);
            Assert.That(contents, Is.EqualTo(@"
            <div>
            <p>2</p>
            </div>"));
            Assert.That(calls, Is.EqualTo(2));
        }
Esempio n. 9
0
 public PhotoService(
     IMemoryCache cache,
     CacheSignal <Photo> cacheSignal,
     ILogger <PhotoService> logger) =>
 (_cache, _cacheSignal, _logger) = (cache, cacheSignal, logger);