Helps you create valid IRequest objects
Наследование: System.Net.Request, IRequest
Пример #1
0
 public void Can_make_new_with_method_and_uri_and_body_as_string()
 {
     request = new RequestWriter("POST", "/dogs", "name=Rover&breed=GoldenRetriever");
     Assert.That(request.Method, Is.EqualTo("POST"));
     Assert.That(request.Uri, Is.EqualTo("/dogs"));
     Assert.That(request.Body, Is.EqualTo("name=Rover&breed=GoldenRetriever"));
 }
Пример #2
0
 public void Can_make_new_with_method_and_uri_and_body_as_bytes()
 {
     byte[] bytes = Encoding.UTF8.GetBytes("Hello there!");
     request = new RequestWriter("POST", "/dogs", bytes);
     Assert.That(request.Method, Is.EqualTo("POST"));
     Assert.That(request.Uri, Is.EqualTo("/dogs"));
     Assert.That(request.BodyBytes, Is.EqualTo(bytes));
     Assert.That(request.Body, Is.EqualTo("Hello there!"));
 }
Пример #3
0
		public void Validates_incoming_Request() {
		    IRequest goodRequest = new RequestWriter("GET", "/");
		    GetResponse(goodRequest);
		    Assert.That(LastResponse.BodyText, Is.EqualTo("You requested GET /"));
		    Assert.That(LastResponse.BodyText, Is.Not.StringContaining("LintException"));

		    IRequest badRequest = new RequestWriter().SetMethod(""); // blank Method
		    GetResponse(badRequest);
		    Assert.That(LastResponse.BodyText, Is.StringContaining("Owin.LintException: Request was not valid: Method cannot be blank"));
		}
Пример #4
0
 public void Can_make_new_with_method_and_uri()
 {
     request = new RequestWriter("POST", "/dogs");
     Assert.That(request.Method, Is.EqualTo("POST"));
     Assert.That(request.Uri, Is.EqualTo("/dogs"));
 }
Пример #5
0
 public void Before()
 {
     request = new Owin.RequestWriter();
 }
Пример #6
0
 public void Can_make_new_with_just_uri_which_defaults_to_get()
 {
     request = new RequestWriter("/cats");
     Assert.That(request.Method, Is.EqualTo("GET"));
     Assert.That(request.Uri, Is.EqualTo("/cats"));
 }
Пример #7
0
 public void Can_SetUri()
 {
     request = new RequestWriter().SetMethod("PUT");
     Assert.That(request.Method, Is.EqualTo("PUT"));
 }
Пример #8
0
 public void SetHeader_automatically_lowercases_header_keys_as_required_by_the_owin_spec()
 {
     request = new RequestWriter().SetHeader("CONTENT-type", "application/json");
     Assert.That(request.Headers["content-type"], Is.EqualTo(new string[] { "application/json" }));
 }
Пример #9
0
 public void Can_SetItem()
 {
     request = new RequestWriter().SetItem("owin.num", 5).SetItem("owin.decimal", 12.34).SetItem("owin.string", "hello!");
     Assert.That(request.Items["owin.num"], Is.EqualTo(5));
     Assert.That(request.Items["owin.decimal"], Is.EqualTo(12.34));
     Assert.That(request.Items["owin.string"], Is.EqualTo("hello!"));
 }
Пример #10
0
 public void Can_SetHeader_with_string()
 {
     request = new RequestWriter().SetHeader("content-type", "application/json");
     Assert.That(request.Headers["content-type"], Is.EqualTo(new string[] { "application/json" }));
 }
Пример #11
0
 public void Can_SetBody_with_string()
 {
     request = new RequestWriter().SetBody("Hi there");
     Assert.That(request.Body, Is.EqualTo("Hi there"));
     Assert.That(request.BodyBytes, Is.EqualTo(Encoding.UTF8.GetBytes("Hi there")));
 }
Пример #12
0
                public void Can_AddToBody_with_bytes()
                {
                    byte[] first = Encoding.UTF8.GetBytes("first");
                    byte[] second = Encoding.UTF8.GetBytes("second");
                    byte[] firstAndSecond = Encoding.UTF8.GetBytes("firstsecond");

                    request = new RequestWriter().SetBody(first).SetBody(second);
                    Assert.That(request.Body, Is.EqualTo("second"));
                    Assert.That(request.BodyBytes, Is.EqualTo(second));

                    request = new RequestWriter().SetBody(first).AddToBody(second);
                    Assert.That(request.Body, Is.EqualTo("firstsecond"));
                    Assert.That(request.BodyBytes, Is.EqualTo(firstAndSecond));
                }
Пример #13
0
                public void Can_AddHeader_which_adds_to_the_IEnumerable_with_string()
                {
                    request = new RequestWriter().SetHeader("content-type", "application/json").SetHeader("content-type", "application/second");
                    Assert.That(request.Headers["content-type"], Is.EqualTo(new string[] { "application/second" }));

                    // Now use AddHeader, and both values should be present
                    request = new RequestWriter().SetHeader("content-type", "application/json").AddHeader("content-type", "application/second");
                    Assert.That(request.Headers["content-type"], Is.EqualTo(new string[] { "application/json", "application/second" }));
                }