public void the_content_is_written_to_the_stream()
        {
            var codec = new JsonDataContractCodec();
            var stub  = new InMemoryResponse();

            codec.WriteTo(new Customer {
                Name = "hello"
            }, stub.Entity, null);

            stub.Entity.Stream.Position.ShouldNotBe(0);
        }
        public void Given_ABasicAuthenticatorWithARealm_When_ChallengingAResponse_Then_TheResponseHasAWWWAuthenticateHeader()
        {
            // given
            string realm    = "Lex Luthors Palace";
            var    response = new InMemoryResponse();

            _mockAuthenticator
            .SetupGet(auth => auth.Realm)
            .Returns(realm);

            // when
            _basicScheme.Challenge(response);

            // then
            var expectedChallengeHeader = string.Format("Basic realm=\"{0}\"", realm);

            response.Headers.ShouldContain("WWW-Authenticate", expectedChallengeHeader);
        }
Пример #3
0
            private void ReadResponse(InMemoryResponse response)
            {
                response.Entity.Stream.Position = 0;

                ResponseText = new StreamReader(response.Entity.Stream).ReadToEnd();
            }
Пример #4
0
 public void when_I_write(object obj)
 {
     response = new InMemoryResponse();
     Codec.WriteTo(obj, response.Entity, new string[0]);
     ReadResponse(response);
 }
Пример #5
0
 private void ReadResponse(InMemoryResponse response)
 {
     response.Entity.Stream.Position = 0;
     
     ResponseText = new StreamReader(response.Entity.Stream).ReadToEnd();
 }
Пример #6
0
 public void when_I_write(object obj)
 {
     response = new InMemoryResponse();
     Codec.WriteTo(obj, response.Entity, new string[0]);
     ReadResponse(response);
 }