My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.IO;
using System.Text;
using System.Web.Hosting;

namespace CodeBackpack.Test.Http
{
/// <summary>
/// A worker request stub that lets you fake out the HTTP request methods.
/// </summary>
/// <remarks>
/// Only few strategic methods were overriden.
/// </remarks>
internal class WorkerRequestStub : SimpleWorkerRequest
{
private readonly String requestMethod;
private readonly String requestBody;
private readonly Encoding requestEncoding;
private byte[] entityBody;

public WorkerRequestStub(String requestMethod, String requestBody, Encoding requestEncoding, String page, String query, StringWriter output)
: base("/it/does/not/matter", @"I:\t\does\not\matter", page, query, output)
{
this.requestMethod = requestMethod;
this.requestBody = requestBody;
this.requestEncoding = requestEncoding;
}

public override String GetHttpVerbName()
{
return requestMethod;
}

public override bool IsEntireEntityBodyIsPreloaded()
{
return true;
}

public override byte[] GetPreloadedEntityBody()
{
if (entityBody == null)
{
if (requestBody == null)
{
throw new ArgumentNullException("requestBody",
"You must supply non-null 'requestBody' argument!");
}
if (requestEncoding == null)
{
throw new ArgumentNullException("requestEncoding",
"You must supply non-null 'requestEncoding' argument!");
}
entityBody = requestEncoding.GetBytes(requestBody);
}
return entityBody;
}
}
}
Show details Hide details

Change log

r18 by prepin on May 14, 2008   Diff
[testhttp] When ImitatePost is used,
ensure the request's ContentLength is
valid.
Go to: 
Project members, sign in to write a code review

Older revisions

r17 by prepin on May 12, 2008   Diff
[testhttp] Minor refactoring &
documentation.
r16 by prepin on May 12, 2008   Diff
A typo in the comment fixed.
r15 by prepin on May 12, 2008   Diff
HttpHandler unit testing - proof of
concept that works.
All revisions of this file

File info

Size: 1873 bytes, 58 lines

File properties

svn:eol-style
native
Hosted by Google Code