public void GetOrCreateValue_TwiceWithNullValue_DoesNotEvalueValueFactoryTwice() { var adapter = new LazyLockingCachingAdapter <string, object>(new Cache <string, DoubleCheckedLockingContainer <Wrapper> >()); bool wasCalled = false; var value = adapter.GetOrCreateValue( "test", s => { Assert.That(wasCalled, Is.False); wasCalled = true; return(null); }); Assert.That(value, Is.Null); value = adapter.GetOrCreateValue("test", s => { throw new InvalidOperationException("Must not be called."); }); Assert.That(value, Is.Null); }
public void SetUp() { _innerCacheMock = MockRepository.GenerateStrictMock <ICache <string, DoubleCheckedLockingContainer <Wrapper> > > (); _cachingAdapter = new LazyLockingCachingAdapter <string, object> (_innerCacheMock); }
private LockingCacheDecorator <string, DoubleCheckedLockingContainer <Wrapper> > GetLockingCacheDecorator( LazyLockingCachingAdapter <string, object> lazyLockingCacheAdapter) { return((LockingCacheDecorator <string, DoubleCheckedLockingContainer <Wrapper> >) PrivateInvoke.GetNonPublicField(lazyLockingCacheAdapter, "_innerCache")); }