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(); }
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(); }
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); }
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); }
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 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)); }