public void CacheResultOfMethodThatReturnsCollection()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.ReturnsCollection).Method;
            object     expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(new object[] { "one", "two", "three" });

            // return value should be added to cache
            object returnValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(1, resultCache.Count);

            // and again, but without Proceed()...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);

            // cached value should be returned
            object cachedValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);

            Assert.AreEqual(expectedReturnValue, cachedValue);
            Assert.AreNotSame(expectedReturnValue, cachedValue);
            Assert.AreEqual(expectedReturnValue, resultCache.Get(5));
            Assert.AreEqual(1, resultCache.Count);
            Assert.AreSame(returnValue, cachedValue);
            Assert.AreSame(cachedValue, resultCache.Get(5));

            mockInvocation.Verify();
            mockContext.Verify();
        }
Esempio n. 2
0
        public void CacheOnlyItemsOfMethodThatReturnsCollectionWithinTwoDifferentCaches()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.MultipleCacheResultItems).Method;
            object     expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(6, itemCache.Count);

            // and again, but without Proceed() and item cache access...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCallToProceed(new object[] { "one", "two", "three" });

            // new return value should be returned
            object newReturnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(expectedReturnValue, newReturnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(6, itemCache.Count);
            Assert.AreEqual("two", itemCache.Get("two"));
            Assert.AreEqual("two", itemCache.Get("TWO"));
            Assert.AreNotSame(returnValue, newReturnValue);
        }
Esempio n. 3
0
        public void AcceptsEnumerableOnlyReturn()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.ReturnsEnumerableOnlyAndItems).Method;

            object[]             args = new object[] { "one", "two", "three" };
            EnumerableOnlyResult expectedReturnValue = new EnumerableOnlyResult(args);

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue.InnerArray);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(expectedReturnValue);
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(1, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);
            Assert.AreSame(expectedReturnValue, returnValue);
            Assert.AreSame(expectedReturnValue, resultCache.Get(5));

            // and again, but without Proceed() and item cache access...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, IGNORED_ARGS);

            // cached value should be returned, cache remains unchanged
            object cachedValue = advice.Invoke(mockInvocation);

            Assert.AreSame(expectedReturnValue, cachedValue);
            Assert.AreSame(returnValue, cachedValue);
            Assert.AreSame(expectedReturnValue, resultCache.Get(5));
            Assert.AreEqual(1, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);
        }
Esempio n. 4
0
        public void CacheResultOfMethodThatReturnsCollectionContainingNullItems()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.ReturnsEnumerableOnlyAndItems).Method;
            object     expectedReturnValue = new object[] { null, "two", null };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(expectedReturnValue);
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke(mockInvocation);

            Assert.AreSame(expectedReturnValue, returnValue);
            Assert.AreEqual(1, resultCache.Count);
            Assert.AreEqual(2, itemCache.Count); // 2 null items result into 1 cached item

            // and again, but without Proceed() and item cache access...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, IGNORED_ARGS);

            // cached value should be returned
            object cachedValue = advice.Invoke(mockInvocation);

            Assert.AreSame(expectedReturnValue, cachedValue);
            Assert.AreSame(returnValue, cachedValue);
            Assert.AreSame(expectedReturnValue, resultCache.Get(5));
            Assert.AreEqual(1, resultCache.Count);
            Assert.AreEqual(2, itemCache.Count);
        }
Esempio n. 5
0
        public void CacheResultAndItemsOfMethodThatReturnsCollection()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.ReturnsCollectionAndItems).Method;
            object     expectedReturnValue = new object[] { "one", "two", "three" };

            using (mocks.Record())
            {
                ExpectAttributeRetrieval(method);
                ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
                ExpectCacheInstanceRetrieval("results", resultCache);
                ExpectCallToProceed(new object[] { "one", "two", "three" });
                ExpectCacheInstanceRetrieval("items", itemCache);
            }

            using (mocks.Playback())
            {
                // return value should be added to result cache and each item to item cache
                object returnValue = advice.Invoke(mockInvocation);
                Assert.AreEqual(expectedReturnValue, returnValue);
                Assert.AreEqual(1, resultCache.Count);
                Assert.AreEqual(3, itemCache.Count);

                // cached value should be returned
                object cachedValue = advice.Invoke(mockInvocation);
                Assert.AreEqual(expectedReturnValue, cachedValue);
                Assert.AreNotSame(expectedReturnValue, cachedValue);
                Assert.AreEqual(expectedReturnValue, resultCache.Get(5));
                Assert.AreEqual(1, resultCache.Count);
                Assert.AreEqual(3, itemCache.Count);
                Assert.AreSame(returnValue, cachedValue);
                Assert.AreSame(cachedValue, resultCache.Get(5));
            }
        }
Esempio n. 6
0
        public void CacheOnlyItemsOfMethodThatReturnsCollection()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.ReturnsItems).Method;
            object     expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);

            ExpectAttributeRetrieval(method);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);

            object newReturnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(expectedReturnValue, newReturnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);
            Assert.AreEqual("two", itemCache.Get("two"));
            Assert.AreNotSame(returnValue, newReturnValue);
        }
Esempio n. 7
0
        public void CacheResultOfMethodThatReturnsCollectionOnCondition()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.CacheResultWithCondition).Method;
            object     expectedReturnValue = new object[] {};

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(new object[] {});

            // return value should not be added to cache
            object returnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(0, resultCache.Count);
        }
Esempio n. 8
0
        public void CacheResultWithMethodInfo()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.CacheResultWithMethodInfo).Method;
            object     expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(new object[] { "one", "two", "three" });

            // return value should be added to cache
            object returnValue = advice.Invoke(mockInvocation);

            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(1, resultCache.Count);
            Assert.AreEqual(returnValue, resultCache.Get("CacheResultWithMethodInfo-5"));
        }
        public void CacheResultItemsWithMethodInfo()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.CacheResultItemsWithMethodInfo).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);
            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);
            Assert.AreEqual("two", itemCache.Get("CacheResultItemsWithMethodInfo-two"));

            mockInvocation.Verify();
            mockContext.Verify();
        }
Esempio n. 10
0
        public void CacheOnlyItemsOfMethodThatReturnsCollectionOnCondition()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.CacheResultItemsWithCondition).Method;
            object     expectedReturnValue = new object[] { "one", "two", "three" };

            using (mocks.Record())
            {
                ExpectAttributeRetrieval(method);
                ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
                ExpectCallToProceed(new object[] { "one", "two", "three" });
                ExpectCacheInstanceRetrieval("items", itemCache);
            }

            using (mocks.Playback())
            {
                // return value should be added to result cache and each item to item cache
                object returnValue = advice.Invoke(mockInvocation);
                Assert.AreEqual(expectedReturnValue, returnValue);
                Assert.AreEqual(2, itemCache.Count);
                Assert.AreEqual("two", itemCache.Get("two"));
                Assert.AreEqual("three", itemCache.Get("three"));
            }
        }
Esempio n. 11
0
        public void CacheResultOfMethodThatReturnsCollectionContainingNullItems()
        {
            MethodInfo method = new EnumerableResultMethod( cacheResultTarget.ReturnsEnumerableOnlyAndItems ).Method;
            object expectedReturnValue = new object[] { null, "two", null };

            ExpectAttributeRetrieval( method );
            ExpectCacheKeyGeneration( method, 5, expectedReturnValue );
            ExpectCacheInstanceRetrieval( "results", resultCache );
            ExpectCallToProceed( expectedReturnValue );
            ExpectCacheInstanceRetrieval( "items", itemCache );

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke( (IMethodInvocation)mockInvocation.Object );
            Assert.AreSame( expectedReturnValue, returnValue );
            Assert.AreEqual( 1, resultCache.Count );
            Assert.AreEqual( 2, itemCache.Count ); // 2 null items result into 1 cached item

            // and again, but without Proceed() and item cache access...
            ExpectAttributeRetrieval( method );
            ExpectCacheKeyGeneration( method, 5, IGNORED_ARGS );
            ExpectCacheInstanceRetrieval( "results", resultCache );

            // cached value should be returned
            object cachedValue = advice.Invoke( (IMethodInvocation)mockInvocation.Object );
            Assert.AreSame(expectedReturnValue, cachedValue);
            Assert.AreSame(returnValue, cachedValue );
            Assert.AreSame(expectedReturnValue, resultCache.Get(5));
            Assert.AreEqual( 1, resultCache.Count );
            Assert.AreEqual( 2, itemCache.Count );

            mockInvocation.Verify();
            mockContext.Verify();
        }
        public void CacheOnlyItemsOfMethodThatReturnsCollectionOnCondition()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.CacheResultItemsWithCondition).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            using (mocks.Record())
            {
                ExpectAttributeRetrieval(method);
                ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
                ExpectCallToProceed(new object[] { "one", "two", "three" });
                ExpectCacheInstanceRetrieval("items", itemCache);
            }

            using (mocks.Playback())
            {
                // return value should be added to result cache and each item to item cache
                object returnValue = advice.Invoke(mockInvocation);
                Assert.AreEqual(expectedReturnValue, returnValue);
                Assert.AreEqual(2, itemCache.Count);
                Assert.AreEqual("two", itemCache.Get("two"));
                Assert.AreEqual("three", itemCache.Get("three"));
            }

        }
        public void CacheOnlyItemsOfMethodThatReturnsCollection()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.ReturnsItems).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            mocks.Record();

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheInstanceRetrieval("items", itemCache);

            mocks.ReplayAll();

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke(mockInvocation);
            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);

            mocks.Verify(mockInvocation);

            mocks.BackToRecord(mockInvocation);

            ExpectAttributeRetrieval(method);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);

            mocks.Replay(mockInvocation);

            object newReturnValue = advice.Invoke(mockInvocation);
            Assert.AreEqual(expectedReturnValue, newReturnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);
            Assert.AreEqual("two", itemCache.Get("two"));
            Assert.AreNotSame(returnValue, newReturnValue);

            mocks.VerifyAll();
        }
Esempio n. 14
0
        public void CacheResultAndItemsOfMethodThatReturnsCollection()
        {
            MethodInfo method = new EnumerableResultMethod( cacheResultTarget.ReturnsCollectionAndItems ).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);
            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(1, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);

            // and again, but without Proceed() and item cache access...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);

            // cached value should be returned
            object cachedValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);
            Assert.AreEqual(expectedReturnValue, cachedValue);
            Assert.AreNotSame(expectedReturnValue, cachedValue);
            Assert.AreEqual(expectedReturnValue, resultCache.Get(5));
            Assert.AreEqual( 1, resultCache.Count );
            Assert.AreEqual( 3, itemCache.Count );
            Assert.AreSame( returnValue, cachedValue );
            Assert.AreSame( cachedValue, resultCache.Get( 5 ) );

            mockInvocation.Verify();
            mockContext.Verify();
        }
        public void CacheResultWithMethodInfo()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.CacheResultWithMethodInfo).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            using (mocks.Record())
            {
                ExpectAttributeRetrieval(method);
                ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
                ExpectCacheInstanceRetrieval("results", resultCache);
                ExpectCallToProceed(new object[] { "one", "two", "three" });
            }

            using (mocks.Playback())
            {
                // return value should be added to cache
                object returnValue = advice.Invoke(mockInvocation);
                Assert.AreEqual(expectedReturnValue, returnValue);
                Assert.AreEqual(1, resultCache.Count);
                Assert.AreEqual(returnValue, resultCache.Get("CacheResultWithMethodInfo-5"));
            }
        }
Esempio n. 16
0
        public void CacheOnlyItemsOfMethodThatReturnsCollectionWithinTwoDifferentCaches()
        {
            MethodInfo method = new EnumerableResultMethod( cacheResultTarget.MultipleCacheResultItems ).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheInstanceRetrieval( "items", itemCache );
            ExpectCacheInstanceRetrieval( "items", itemCache );

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke( (IMethodInvocation)mockInvocation.Object );
            Assert.AreEqual( expectedReturnValue, returnValue );
            Assert.AreEqual( 0, resultCache.Count );
            Assert.AreEqual( 6, itemCache.Count );

            // and again, but without Proceed() and item cache access...
            ExpectAttributeRetrieval( method );
            ExpectCallToProceed( new object[] { "one", "two", "three" } );
            ExpectCacheInstanceRetrieval( "items", itemCache );
            ExpectCacheInstanceRetrieval( "items", itemCache );

            // new return value should be returned
            object newReturnValue = advice.Invoke( (IMethodInvocation)mockInvocation.Object );
            Assert.AreEqual( expectedReturnValue, newReturnValue );
            Assert.AreEqual( 0, resultCache.Count );
            Assert.AreEqual( 6, itemCache.Count );
            Assert.AreEqual( "two", itemCache.Get( "two" ) );
            Assert.AreEqual( "two", itemCache.Get( "TWO" ) );
            Assert.AreNotSame( returnValue, newReturnValue );

            mockInvocation.Verify();
            mockContext.Verify();
        }
Esempio n. 17
0
        public void CacheResultOfMethodThatReturnsCollectionOnCondition()
        {
            MethodInfo method = new EnumerableResultMethod( cacheResultTarget.CacheResultWithCondition ).Method;
            object expectedReturnValue = new object[] { };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(new object[] { });

            // return value should not be added to cache
            object returnValue = advice.Invoke( (IMethodInvocation)mockInvocation.Object );
            Assert.AreEqual( expectedReturnValue, returnValue );
            Assert.AreEqual( 0, resultCache.Count );

            mockInvocation.Verify();
            mockContext.Verify();
        }
Esempio n. 18
0
        public void AcceptsEnumerableOnlyReturn()
        {
            MethodInfo method = new EnumerableResultMethod( cacheResultTarget.ReturnsEnumerableOnlyAndItems ).Method;
            object[] args = new object[] { "one", "two", "three" };
            EnumerableOnlyResult expectedReturnValue = new EnumerableOnlyResult(args);

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue.InnerArray);
            ExpectCacheInstanceRetrieval("results", resultCache);
            ExpectCallToProceed(expectedReturnValue);
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);
            Assert.AreEqual(1, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);
            Assert.AreSame(expectedReturnValue, returnValue);
            Assert.AreSame(expectedReturnValue, resultCache.Get(5));

            // and again, but without Proceed() and item cache access...
            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, IGNORED_ARGS);
            ExpectCacheInstanceRetrieval("results", resultCache);

            // cached value should be returned, cache remains unchanged
            object cachedValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);
            Assert.AreSame(expectedReturnValue, cachedValue);
            Assert.AreSame(returnValue, cachedValue );
            Assert.AreSame(expectedReturnValue, resultCache.Get(5));
            Assert.AreEqual( 1, resultCache.Count );
            Assert.AreEqual( 3, itemCache.Count );

            mockInvocation.Verify();
            mockContext.Verify();
        }
Esempio n. 19
0
        public void CacheResultItemsWithMethodInfo()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.CacheResultItemsWithMethodInfo).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            ExpectAttributeRetrieval(method);
            ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
            ExpectCallToProceed(new object[] { "one", "two", "three" });
            ExpectCacheInstanceRetrieval("items", itemCache);

            // return value should be added to result cache and each item to item cache
            object returnValue = advice.Invoke((IMethodInvocation)mockInvocation.Object);
            Assert.AreEqual(expectedReturnValue, returnValue);
            Assert.AreEqual(0, resultCache.Count);
            Assert.AreEqual(3, itemCache.Count);
            Assert.AreEqual("two", itemCache.Get("CacheResultItemsWithMethodInfo-two"));

            mockInvocation.Verify();
            mockContext.Verify();
        }
        public void CacheResultAndItemsOfMethodThatReturnsCollection()
        {
            MethodInfo method = new EnumerableResultMethod(cacheResultTarget.ReturnsCollectionAndItems).Method;
            object expectedReturnValue = new object[] { "one", "two", "three" };

            using (mocks.Record())
            {
                ExpectAttributeRetrieval(method);
                ExpectCacheKeyGeneration(method, 5, expectedReturnValue);
                ExpectCacheInstanceRetrieval("results", resultCache);
                ExpectCallToProceed(new object[] { "one", "two", "three" });
                ExpectCacheInstanceRetrieval("items", itemCache);

            }

            using (mocks.Playback())
            {
                // return value should be added to result cache and each item to item cache
                object returnValue = advice.Invoke(mockInvocation);
                Assert.AreEqual(expectedReturnValue, returnValue);
                Assert.AreEqual(1, resultCache.Count);
                Assert.AreEqual(3, itemCache.Count);

                // cached value should be returned
                object cachedValue = advice.Invoke(mockInvocation);
                Assert.AreEqual(expectedReturnValue, cachedValue);
                Assert.AreNotSame(expectedReturnValue, cachedValue);
                Assert.AreEqual(expectedReturnValue, resultCache.Get(5));
                Assert.AreEqual(1, resultCache.Count);
                Assert.AreEqual(3, itemCache.Count);
                Assert.AreSame(returnValue, cachedValue);
                Assert.AreSame(cachedValue, resultCache.Get(5));

            }
        }