C# Класс Microsoft.WindowsAzure.Commands.SqlDatabase.Test.UnitTests.MockServer.MockHttpServer

A mock server implementation for capturing and replaying Http Web Requests.
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
DefaultHttpsServerPrefixUri System.Uri
DefaultServerPrefixUri System.Uri

Открытые методы

Метод Описание
CreateWebException ( HttpStatusCode status, MemoryStream content, Action contextHandler ) : WebException

Create a WebException with the specified content.

CreateWebException ( HttpStatusCode status, string content, Action contextHandler ) : WebException

Create a WebException with the specified content.

Dispose ( ) : void

Stop and closes the listener.

MockHttpServer ( AsyncExceptionManager exceptionManager, Uri baseUri, Microsoft.WindowsAzure.Commands.SqlDatabase.Test.UnitTests.MockServer.HttpSession session ) : System

Initializes a new instance of the MockHttpServer class that record or playback responses for requests in a session.

SetupCertificates ( ) : void

Setup certificates required for the unit tests

Приватные методы

Метод Описание
ChangeUriBase ( Uri originalUri, Uri originalUriPrefix, Uri newPrefix ) : Uri

Returns the originalUri with its prefix changed from originalUriPrefix to newPrefix, or if the prefix is not in the originalUri, return the Uri as is.

ConstructListenerResponse ( HttpMessage responseInfo, Uri baseUri, HttpListenerResponse response ) : void

Constructs the response from the specified HttpMessage.Response.

ConstructRequestInfo ( HttpListenerRequest originalRequest ) : HttpMessage.Request

Create an HttpMessage.Request object out of the given originalRequest.

ConstructResponseInfo ( Uri serviceBaseUri, HttpWebResponse response ) : HttpMessage.Response

Create an HttpMessage.Response object out of the response from a service.

CreateListener ( Action contextHandler, int requestsToHandle ) : HttpListener

Create a HttpListener to handles requests.

ExecuteProcess ( string filename, string arguments ) : Process

Helper method to execute and wait for process to complete.

GetResponseInfoFromService ( HttpListenerRequest request, Uri baseUri, Uri serviceBaseUri, Microsoft.WindowsAzure.Commands.SqlDatabase.Test.UnitTests.MockServer.HttpSession session ) : HttpMessage

Retrieves an HttpMessage object from a real service.

HandleMockRequest ( HttpListenerContext context, Uri baseUri, Microsoft.WindowsAzure.Commands.SqlDatabase.Test.UnitTests.MockServer.HttpSession session ) : void

The async delegate that handles an incoming request, passing it through to a real service and record the response if serviceBaseUri was specified, or plays back responses from a pre-recorded session if it was not.

HandleRequest ( IAsyncResult ar, Action contextHandler, int requestsToHandle ) : void

The async delegate that handles an incoming request.

MakeServiceRequest ( HttpMessage originalRequest ) : HttpWebResponse

Make an request to the real service and retrieve the response.

MockHttpServer ( AsyncExceptionManager exceptionManager, Uri baseUri ) : System

Initializes a new instance of the MockHttpServer class with a specified server prefix.

Описание методов

CreateWebException() публичный статический Метод

Create a WebException with the specified content.
public static CreateWebException ( HttpStatusCode status, MemoryStream content, Action contextHandler ) : WebException
status HttpStatusCode The status code to use in the exception.
content System.IO.MemoryStream A of the exception content.
contextHandler Action An action that adds extra info to the response.
Результат System.Net.WebException

CreateWebException() публичный статический Метод

Create a WebException with the specified content.
public static CreateWebException ( HttpStatusCode status, string content, Action contextHandler ) : WebException
status HttpStatusCode The status code to use in the exception.
content string The exception content.
contextHandler Action An action that adds extra info to the response.
Результат System.Net.WebException

Dispose() публичный Метод

Stop and closes the listener.
public Dispose ( ) : void
Результат void

MockHttpServer() публичный Метод

Initializes a new instance of the MockHttpServer class that record or playback responses for requests in a session.
public MockHttpServer ( AsyncExceptionManager exceptionManager, Uri baseUri, Microsoft.WindowsAzure.Commands.SqlDatabase.Test.UnitTests.MockServer.HttpSession session ) : System
exceptionManager AsyncExceptionManager /// The exception manager that captures all async exceptions. ///
baseUri System.Uri The server prefix to use.
session Microsoft.WindowsAzure.Commands.SqlDatabase.Test.UnitTests.MockServer.HttpSession The object that stores request/response information.
Результат System

SetupCertificates() публичный статический Метод

Setup certificates required for the unit tests
public static SetupCertificates ( ) : void
Результат void

Описание свойств

DefaultHttpsServerPrefixUri публичное статическое свойство

The HTTPS server prefix for tests which is been used in cert auth based unit tests
public static Uri,System DefaultHttpsServerPrefixUri
Результат System.Uri

DefaultServerPrefixUri публичное статическое свойство

The HTTP server prefix for tests
public static Uri,System DefaultServerPrefixUri
Результат System.Uri