Beispiel #1
0
        public void Put_ValueIsNull_Constructor_CacheIsNull_ArgumentNullExceptionIsThrown()
        {
            var cacheMock = new Mock <ICache <object> >();
            var sut       = new CacheAdapter(cacheMock.Object);

            Assert.Throws <ArgumentNullException>(() => sut.Put("key", null));
        }
Beispiel #2
0
        private object executeAndPutInCache(MethodInfo method, object[] arguments, EventInformation eventInformation)
        {
            var retVal = callOriginalMethod(method, arguments);

            _cache.Put(new CachedItem(eventInformation, retVal));
            return(retVal);
        }
Beispiel #3
0
        public void Put_ValueIsNull_Constructor_CacheIsNull_ArgumentNullExceptionIsThrown()
        {
            var cacheMock  = new Mock <ICache <string> >();
            var cacheMock2 = new Mock <ICache <StoredHttpResponseMessage> >();

            var sut = new CacheAdapter(cacheMock.Object, cacheMock2.Object);

            Assert.Throws <ArgumentNullException>(() => sut.Put("key", (string)null));
        }
Beispiel #4
0
        public void Put_ParametersAreValid_CachePutIsCalled()
        {
            var keyToCheck   = "key";
            var valueToCheck = "value";
            var cacheMock    = new Mock <ICache <object> >();
            var sut          = new CacheAdapter(cacheMock.Object);

            sut.Put(keyToCheck, valueToCheck);

            cacheMock.Verify(cache => cache.Put(It.Is <string>(key => key == keyToCheck), It.Is <object>(value => (string)value == valueToCheck)), Times.Once);
        }
Beispiel #5
0
        public void Put_ParametersAreValidResponse_CachePutIsCalled()
        {
            var keyToCheck = "key";

            var cacheMock  = new Mock <ICache <string> >();
            var cacheMock2 = new Mock <ICache <StoredHttpResponseMessage> >();

            var sut = new CacheAdapter(cacheMock.Object, cacheMock2.Object);

            sut.Put(keyToCheck, new StoredHttpResponseMessage());

            cacheMock2.Verify(cache => cache.Put(It.Is <string>(key => key == keyToCheck), It.IsAny <StoredHttpResponseMessage>()), Times.Once);
        }
Beispiel #6
0
 private void executeAndPutInCache(IInvocation invocation, EventInformation eventInfo)
 {
     invocation.Proceed();
     _cache.Put(new CachedItem(eventInfo, invocation.ReturnValue));
 }