public void Should_be_implemented() { var request = new FakeHttpRequest(); Assert.That(request.ApplicationPath, Is.Null); Assert.That(request.AcceptTypes, Is.EquivalentTo(new string[] { })); }
public void Can_access_form_values_by_default_indexer() { var request = new FakeHttpRequest(); request.Form.Add("color", "blue"); Assert.That(request["color"], Is.EqualTo("blue")); }
public void Can_specify_request() { var request = new FakeHttpRequest(); var context = new FakeHttpContext(request); Assert.That(context.Request, Is.SameAs(request)); }
public void Can_add_and_read_from_server_variables() { var request = new FakeHttpRequest(); request.ServerVariables.Add("REMOTE_ADDR", "127.0.0.1"); Assert.That(request.ServerVariables["REMOTE_ADDR"], Is.EqualTo("127.0.0.1")); }
public void Can_set_authenticated_status() { var request = new FakeHttpRequest(); Assert.That(request, Has.Property("IsAuthenticated").False); request.Set(req => req.IsAuthenticated, true); Assert.That(request, Has.Property("IsAuthenticated").True); }
public void Can_add_to_form_collection() { var request = new FakeHttpRequest(); request.Form.Add("color", "blue"); Assert.That(request.Form["color"], Is.EqualTo("blue")); }
public void Should_add_to_query_string() { var request = new FakeHttpRequest(); request.QueryString.Add("id", "3"); Assert.That(request.QueryString["id"], Is.EqualTo("3")); }
public void Can_access_query_string_values_by_default_indexer() { var request = new FakeHttpRequest(); request.QueryString.Add("id", "3"); Assert.That(request["id"], Is.EqualTo("3")); }
public void Url_query_string_should_add_to_query_string_collection() { var url = new Uri("http://google.com?q=awesome&p=1"); var request = new FakeHttpRequest(url); Assert.That(request.QueryString["q"], Is.EqualTo("awesome")); Assert.That(request.QueryString["p"], Is.EqualTo("1")); }
public void FakeHttpRequest_CurrentExecutionFilePath_Default_ReturnsCorrectPath() { var request = new FakeHttpRequest(new Uri("http://127.0.0.1/app/folder/file.aspx/extra?var=val"), "GET"); request.SetApplicationPath("/app"); var result = request.CurrentExecutionFilePath; Assert.That(result, Is.EqualTo("/app/folder/file.aspx")); }
public void FakeHttpRequest_PathInfo_Default_ReturnsPathInfo() { var request = new FakeHttpRequest(new Uri("http://127.0.0.1/app/folder/file.aspx/extra?var=val"), "GET"); request.SetApplicationPath("/app"); var result = request.PathInfo; Assert.That(result, Is.EqualTo("/extra")); }
public void Should_replace_query_string_when_url_is_changed() { var original = new Uri("http://google.com?q=original"); var changed = new Uri("http://google.com?q=changed"); var request = new FakeHttpRequest(original).SetUrl(changed); Assert.That(request.QueryString["q"], Is.EqualTo("changed")); }
public void Can_set_and_RetrieveInputStream() { var request = new FakeHttpRequest(); var requestBodyText = "This is the raw request body."; var bytes = Encoding.UTF8.GetBytes(requestBodyText); var stream = new MemoryStream(bytes, false); request.SetInputStream(stream); var gotStream = request.InputStream; var rdr = new StreamReader(gotStream, Encoding.UTF8); Assert.That(rdr.ReadToEnd(), Is.EqualTo(requestBodyText)); }
public void Can_add_and_read_from_files() { var request = new FakeHttpRequest(); var files = new FakeHttpFileCollection(); var bytes = Encoding.UTF8.GetBytes("These are file contents"); var fileContents = new MemoryStream(); fileContents.Write(bytes, 0, bytes.Length); fileContents.Flush(); fileContents.Position = 0; var file = new FakeHttpPostedFile("SomeFile.txt", "text/plain", fileContents); files.Add("FileFormFieldValue", file); request.SetFiles(files); Assert.That(request.Files.Count, Is.EqualTo(1)); Assert.That(request.Files[0].FileName, Is.EqualTo("SomeFile.txt")); Assert.That(request.Files[0].ContentType, Is.EqualTo("text/plain")); Assert.That(request.Files[0].ContentLength, Is.EqualTo(fileContents.Length)); }
public void Should_set_value() { var request = new FakeHttpRequest(); var uri = new Uri("http://localhost/"); request.Set(req => req.UrlReferrer, uri); Assert.That(request, Has.Property("UrlReferrer").EqualTo(uri)); }
public void Url_can_be_set() { var request = new FakeHttpRequest(new Uri("http://google.com/")); Assert.That(request.Url.AbsoluteUri, Is.EqualTo("http://google.com/")); }
public FakeHttpContext(string url) { _request = new FakeHttpRequest(url); }