public static void TestGetReturnsBadRequestIfBothIfModifiedAndIfUnmodifiedExist()
		{
			// setup
			var request = new HttpRequestMessage(HttpMethod.Get, TestUrl);
			request.Headers.Add(HttpHeaderNames.IfModifiedSince, DateTimeOffset.Now.ToString("r"));
			request.Headers.Add(HttpHeaderNames.IfUnmodifiedSince, DateTimeOffset.Now.ToString("r"));
			var entityTagHandler = new CachingHandler();
			var getRule = entityTagHandler.GetIfModifiedUnmodifiedSince();

			// run
			var task = getRule(request);
			var httpResponseMessage = task.Result;

			// verify
			Assert.AreEqual(HttpStatusCode.BadRequest, httpResponseMessage.StatusCode);
		}
		public static void GetModifiedNotModifiedTest(
				string headerName,
				bool resourceHasChanged,
				bool expectReturnNull,
				HttpStatusCode expectedStatus = HttpStatusCode.Unused)
		{
			// setup 
			var mocks = new MockRepository();
			var entityTagStore = mocks.StrictMock<IEntityTagStore>();
			var entityTagHandler = new CachingHandler(entityTagStore);
			var request = new HttpRequestMessage(HttpMethod.Get, TestUrl);
			DateTimeOffset lastChanged = DateTimeOffset.Now.Subtract(TimeSpan.FromDays(7));
			DateTimeOffset lastModifiedInQuestion = resourceHasChanged
			                                        	? lastChanged.Subtract(TimeSpan.FromDays(1))
			                                        	: lastChanged.Add(TimeSpan.FromDays(1));

			request.Headers.Add(headerName, lastModifiedInQuestion.ToString("r"));
			var entityTagHeaderValue = new TimedEntityTagHeaderValue("\"12345678\"")
				{LastModified = lastChanged};

			entityTagStore.Expect(x => x.TryGetValue(Arg<EntityTagKey>.Matches(etg => etg.ResourceUri == entityTagHandler.UriTrimmer(new Uri(TestUrl))),
				out Arg<TimedEntityTagHeaderValue>.Out(entityTagHeaderValue).Dummy)).Return(true);

			mocks.ReplayAll();


			// run 
			var modifiedUnmodifiedSince = entityTagHandler.GetIfModifiedUnmodifiedSince();
			var task = modifiedUnmodifiedSince(request);
			HttpResponseMessage response = task == null ? null : task.Result;

			// verify 
			Assert.That(expectReturnNull ^ task != null, "result was not as expected");
			if (task != null && expectedStatus != HttpStatusCode.Unused)
			{
				Assert.AreEqual(expectedStatus, response.StatusCode, "Status code");
			}
			mocks.VerifyAll();

		}
		public static void TestGetModifiedUnmodifiedReturnsNullIfNoneDefined()
		{
			// setup
			var request = new HttpRequestMessage(HttpMethod.Get, TestUrl);
			var entityTagHandler = new CachingHandler();
			var getRule = entityTagHandler.GetIfModifiedUnmodifiedSince();
			// run
			var task = getRule(request);

			// verify
			Assert.IsNull(task);
		}