public void SetUp()
        {
            _response = null;
            _lookupKey = "my lookupKey";
            _fixedUpCacheKey = "cache key for: " + _lookupKey;
            _flushMode = null;

            _cacheTimeout = RMM.GenerateMock<ICacheTimeout>();
            _configurationMock = RMM.GenerateMock<IBlendedCacheConfiguration>();
            RME.Stub(_configurationMock, x => x.GetCacheTimeoutForTypeOrDefault(typeof(TDataMock))).Return(_cacheTimeout);

            _cacheItemMetrics = new CachedItemMetrics(_lookupKey, _fixedUpCacheKey);

            _cacheKeyConverterMock = RMM.GenerateStrictMock<ICacheKeyConverter>();
            RME.Stub(_cacheKeyConverterMock, x => x.ConvertCacheKey<TDataMock, string>(null, _lookupKey)).Do(new Func<string, string, string>((a, b) => _fixedUpCacheKey));

            _contextCachedObject = null;
            _contextCacheLookupMock = RMM.GenerateStrictMock<IContextCacheLookup>();
            RME.Stub(_contextCacheLookupMock, x => x.GetDataFromContextCache<TDataMock>(_fixedUpCacheKey)).Do(new Func<string, TDataMock>((a) => _contextCachedObject));

            _volatileCachedObject = null;
            _volatileCacheLookupMock = RMM.GenerateStrictMock<IVolatileCacheLookup>();
            RME.Stub(_volatileCacheLookupMock, x=>x.GetDataFromVolatileCache<TDataMock>(_fixedUpCacheKey, _cacheItemMetrics)).Do(new Func<string, CachedItemMetrics, TDataMock>((a, b) => _volatileCachedObject));

            _longTermCachedObject = null;
            _longTermCacheLookupMock = RMM.GenerateStrictMock<ILongTermCacheLookup>();
            RME.Stub(_longTermCacheLookupMock, x => x.GetDataFromLongTermCache<TDataMock>(_fixedUpCacheKey, _cacheItemMetrics)).Do(new Func<string, CachedItemMetrics, TDataMock>((a, b) => _longTermCachedObject));

            _cacheSetterMock = RMM.GenerateMock<ICacheSetter>();

            _contextCacheMock = RMM.GenerateMock<IContextCache>();
            _volatileCacheMock = RMM.GenerateMock<IVolatileCache>();
            _longTermCacheMock = RMM.GenerateMock<ILongTermCache>();
        }
Пример #2
0
        public void SetUp()
        {
            _cachedItem = new TDataMock();
            _cacheKey = new DefaultCacheKeyConverter().ConvertCacheKey<TDataMock, int>("", _lookupKey);

            _cacheTimeout = RMM.GenerateStrictMock<ICacheTimeout>();

            _contextCacheMock = RMM.GenerateStrictMock<IContextCache>();
            _volatileCacheMock = RMM.GenerateStrictMock<IVolatileCache>();
            _longTermCacheMock = RMM.GenerateStrictMock<ILongTermCache>();

            _configurationMock = RMM.GenerateStub<IBlendedCacheConfiguration>();
            RME.Stub(_configurationMock, x => x.GetCacheTimeoutForTypeOrDefault(_cachedItem.GetType())).Return(_cacheTimeout);

            _setterMock = RMM.GenerateStrictMock<ICacheSetter>();
            RME.Stub(_setterMock, x => x.Set<TDataMock>(null, null, null, SetCacheLocation.NotSet, null, null, null)).IgnoreArguments()
                .Do(new Action<string, TDataMock, ICacheTimeout, SetCacheLocation, IContextCache, IVolatileCache, ILongTermCache>(
                    (passedCacheKey, passedCachedItem, passedTimeout, passedLocation, passedContext, passedVolatile, passedLongTerm) =>
                    {
                        _passedCacheKey = passedCacheKey;
                        _passedCachedItem = passedCachedItem;
                        _passedCacheTimeout = passedTimeout;
                        _passedCacheLocation = passedLocation;
                        _passedContextCache = passedContext;
                        _passedVolatileCache = passedVolatile;
                        _passedLongTermCache = passedLongTerm;
                    }));
        }