public static void TestPutIfMatchReturnsNullIfVerbNotPut()
        {
            // setup
            var request          = new HttpRequestMessage(HttpMethod.Get, TestUrl);
            var entityTagHandler = new CachingHandler(new HttpConfiguration());
            var getRule          = entityTagHandler.PutIfMatch();

            // run
            var task = getRule(request);

            // verify
            Assert.IsNull(task);
        }
        public static void PutIfMatchTest(
            string[] values,
            bool existsInStore,
            bool expectReturnNull,
            HttpStatusCode expectedStatus = HttpStatusCode.Unused)
        {
            // setup
            var mocks            = new MockRepository();
            var entityTagStore   = mocks.StrictMock <IEntityTagStore>();
            var entityTagHandler = new CachingHandler(new HttpConfiguration(), entityTagStore);
            var request          = new HttpRequestMessage(HttpMethod.Put, TestUrl);

            request.Headers.Add(HttpHeaderNames.IfMatch, values);
            TimedEntityTagHeaderValue entityTagHeaderValue = new TimedEntityTagHeaderValue("\"12345678\"");

            if (values.Length > 0)             // if
            {
                entityTagStore.Expect(x => x.TryGetValue(Arg <CacheKey> .Matches(etg => etg.ResourceUri == entityTagHandler.UriTrimmer(new Uri(TestUrl))),
                                                         out Arg <TimedEntityTagHeaderValue> .Out(entityTagHeaderValue).Dummy)).Return(existsInStore);
            }

            mocks.ReplayAll();


            // run
            var matchNoneMatch = entityTagHandler.PutIfMatch();
            // verify
            Task <HttpResponseMessage> resultTask = matchNoneMatch(request);

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