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

            // verify
            Assert.IsNull(task);
        }
        public static void PutIfUnmodifiedTest(
				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.Put, 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(HttpHeaderNames.IfUnmodifiedSince, lastModifiedInQuestion.ToString("r"));
            TimedEntityTagHeaderValue entityTagHeaderValue = new TimedEntityTagHeaderValue("\"12345678\"") { LastModified = lastChanged };

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

            mocks.ReplayAll();

            // run
            var modifiedUnmodifiedSince = entityTagHandler.PutIfUnmodifiedSince();
            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();
        }