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)); }
private object executeAndPutInCache(MethodInfo method, object[] arguments, EventInformation eventInformation) { var retVal = callOriginalMethod(method, arguments); _cache.Put(new CachedItem(eventInformation, retVal)); return(retVal); }
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)); }
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); }
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); }
private void executeAndPutInCache(IInvocation invocation, EventInformation eventInfo) { invocation.Proceed(); _cache.Put(new CachedItem(eventInfo, invocation.ReturnValue)); }