public void ClearSnapshotWithWatches(bool ads) { var cache = new SimpleCache <string>(_ => "key"); cache.SetSnapshot("key", SNAPSHOT1); var discoveryRequest = new DiscoveryRequest { Node = new Node(), TypeUrl = "" }; var watch = cache.CreateWatch( ads, discoveryRequest, EmptySet, _ => { }); // clearSnapshot should fail and the snapshot should be left untouched cache.ClearSnapshot("key").Should().BeFalse(); cache.GetSnapshot("key").Should().Be(SNAPSHOT1); cache.GetStatusInfo("key").Should().NotBeNull(); watch.Cancel(); // now that the watch is gone we should be able to clear it cache.ClearSnapshot("key").Should().BeTrue(); cache.GetSnapshot("key").Should().BeNull(); cache.GetStatusInfo("key").Should().BeNull(); }
public void ClearSnapshot() { var cache = new SimpleCache <string>(_ => "key"); cache.SetSnapshot("key", SNAPSHOT1); cache.ClearSnapshot("key").Should().BeTrue(); cache.GetSnapshot("key").Should().BeNull(); }