public void UsesSuppliedFormsSigner()
        {
            ISignForms formsSigner = new DummyFormsSigner("output");

            var processor = new FormsIntegrityResponseHandler(formsSigner);
            var response = new HttpResponseMessage {Content = new StringContent("input")};

            var newResponse = processor.OnHandle(response);

            Assert.AreEqual("output", newResponse.Content.ReadAsString());
        }
        public void DoesNotUseSuppliedFormsSignerIfEntityBodyIsNull()
        {
            var mockFormsSigner = MockRepository.GenerateMock<ISignForms>();

            var processor = new FormsIntegrityResponseHandler(mockFormsSigner);
            var response = new HttpResponseMessage();

            processor.OnHandle(response);

            mockFormsSigner.AssertWasNotCalled(fs => fs.SignForms(null, null), fs => fs.IgnoreArguments());
        }
        public void ShouldRetainExistingContentResponseHeaders()
        {
            var dateTime = new DateTimeOffset(new DateTime(2011, 1, 10));

            var processor = new FormsIntegrityResponseHandler(new DummyFormsSigner(string.Empty));

            var response = new HttpResponseMessage {Content = new StringContent("input")};
            response.Content.Headers.ContentType = new MediaTypeHeaderValue(RestbucksMediaType.Value);
            response.Content.Headers.Expires = dateTime;

            var newResponse = processor.OnHandle(response);

            Assert.AreEqual(RestbucksMediaType.Value, newResponse.Content.Headers.ContentType.MediaType);
            Assert.AreEqual(dateTime, newResponse.Content.Headers.Expires.Value);
        }