Ejemplo n.º 1
0
        public void TestCacheResultDoesNotReturnInvalidType()
        {
            ICache cache = new NonExpiringCache();

            context.ObjectFactory.RegisterSingleton("inventors", cache);

            ProxyFactory pf = new ProxyFactory(new InventorStore());

            pf.AddAdvisors(cacheAspect);

            IInventorStore store = (IInventorStore)pf.GetProxy();

            cache.Insert("Nikola Tesla", "WrongTypeForMethodSignature");

            Inventor value = store.Load("Nikola Tesla");

            Assert.That(value, Is.AssignableTo(typeof(Inventor)), "CacheAspect returned a cached type that is incompatible with the method signature return type");
        }