Ejemplo n.º 1
0
        public void Test_NonCacheableRequest_TypicalCacheDirective()
        {
            var target     = new MyService();
            var request    = new NonCacheableRequest();
            var response   = new object();
            var directive  = new ResponseCachingDirective(true, TimeSpan.FromMinutes(1), ResponseCachingSite.Server);
            var invocation = new TestInvocation
            {
                Target   = target,
                Method   = target.GetType().GetMethod("MyServiceOperation"),
                Request  = request,
                Response = response
            };

            // a non-null cache directive on a non-cacheable request type should throw
            var advice = new ConcreteResponseCachingAdvice(directive);

            advice.Intercept(invocation);
        }
Ejemplo n.º 2
0
        public void Test_NonCacheableRequest_NullCacheDirective()
        {
            var target     = new MyService();
            var request    = new NonCacheableRequest();
            var response   = new object();
            var invocation = new TestInvocation
            {
                Target   = target,
                Method   = target.GetType().GetMethod("MyServiceOperation"),
                Request  = request,
                Response = response
            };

            var advice = new ConcreteResponseCachingAdvice(null);

            advice.Intercept(invocation);

            Assert.IsTrue(invocation.DidProceed);
            Assert.AreEqual(invocation.ReturnValue, response);
        }
		public void Test_NonCacheableRequest_TypicalCacheDirective()
		{
			var target = new MyService();
			var request = new NonCacheableRequest();
			var response = new object();
			var directive = new ResponseCachingDirective(true, TimeSpan.FromMinutes(1), ResponseCachingSite.Server);
			var invocation = new TestInvocation
			{
				Target = target,
				Method = target.GetType().GetMethod("MyServiceOperation"),
				Request = request,
				Response = response
			};

			// a non-null cache directive on a non-cacheable request type should throw
			var advice = new ConcreteResponseCachingAdvice(directive);
			advice.Intercept(invocation);
		}
		public void Test_NonCacheableRequest_NullCacheDirective()
		{
			var target = new MyService();
			var request = new NonCacheableRequest();
			var response = new object();
			var invocation = new TestInvocation
								{
									Target = target,
									Method = target.GetType().GetMethod("MyServiceOperation"),
									Request = request,
									Response = response
								};

			var advice = new ConcreteResponseCachingAdvice(null);
			advice.Intercept(invocation);

			Assert.IsTrue(invocation.DidProceed);
			Assert.AreEqual(invocation.ReturnValue, response);
		}