/// <summary> /// Updates the <see cref="ConstructorNameSuffix"/> property. Invalidates all necessary caches too. /// </summary> /// <param name="suffix">New value for constructor name suffix.</param> public virtual void UpdateConstructorNameSuffix(string suffix) { ConstructorNameSuffix = suffix; constructorNameCache.InvalidateCache(); typeNameCache.InvalidateCache(); fullTypeNameCache.InvalidateCache(); namespaceCache.InvalidateCache(); }
public void Disposable() { int disposedCount = 0; using (SimpleCacheStruct <DisposableAction> cache = SimpleCache.CreateStruct(() => new DisposableAction(() => disposedCount++))) { var v0 = cache.Value; cache.InvalidateCache(); Assert.Equal(1, disposedCount); var v1 = cache.Value; } Assert.Equal(2, disposedCount); }
public void EvaluationAfterInvalidate() { int count = 0; SimpleCacheStruct <int> cache = SimpleCache.CreateStruct(() => { count++; return(42); }); Assert.Equal(0, count); Assert.Equal(42, cache.Value); Assert.Equal(1, count); Assert.Equal(42, cache.Value); Assert.Equal(1, count); cache.InvalidateCache(); Assert.Equal(1, count); Assert.Equal(42, cache.Value); Assert.Equal(2, count); }
public void SettingValue() { int count = 0; SimpleCacheStruct <int> cache = SimpleCache.CreateStruct(() => { count++; return(42); }); Assert.Equal(0, count); Assert.Equal(42, cache.Value); Assert.Equal(1, count); cache.Value = 12345; Assert.Equal(12345, cache.Value); Assert.Equal(1, count); cache.InvalidateCache(); Assert.Equal(1, count); Assert.Equal(42, cache.Value); Assert.Equal(2, count); }