本文整理汇总了C#中ThoughtWorks.CruiseControl.Remote.Messages.ServerRequest类的典型用法代码示例。如果您正苦于以下问题:C# ServerRequest类的具体用法?C# ServerRequest怎么用?C# ServerRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerRequest类属于ThoughtWorks.CruiseControl.Remote.Messages命名空间,在下文中一共展示了ServerRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMessage
/// <summary>
/// Sends a message to a remote server.
/// </summary>
/// <param name="action">The action to perform.</param>
/// <param name="request">The request to send to the server.</param>
/// <returns>The response from the server.</returns>
public Response SendMessage(string action, ServerRequest request)
{
// Make sure there is a password
if ((cryptoKey.Length == 0) || (cryptoIv.Length == 0)) InitialisePassword();
// Generate the encrypted request
var encryptedRequest = new EncryptedRequest();
encryptedRequest.Action = action;
var crypto = new RijndaelManaged();
crypto.Key = cryptoKey;
crypto.IV = cryptoIv;
encryptedRequest.EncryptedData = EncryptMessage(crypto, request.ToString());
// Send the request
var response = innerConnection.SendMessage("ProcessSecureRequest", encryptedRequest);
var encryptedResponse = response as EncryptedResponse;
// Generate the actual response
if ((response.Result == ResponseResult.Success) && (encryptedResponse != null))
{
var data = DecryptMessage(crypto, encryptedResponse.EncryptedData);
response = XmlConversionUtil.ProcessResponse(data);
}
return response;
}
示例2: SendMessageSendsAndReceivesAMessage
public void SendMessageSendsAndReceivesAMessage()
{
var action = "DoSomething";
var request = new ServerRequest
{
ServerName = "TestServer"
};
var url = "http://somewhere/";
var factory = new TestClientFactory((u, a, d) =>
{
Assert.AreEqual(url + "server/TestServer/RawXmlMessage.aspx", u.AbsoluteUri);
Assert.AreEqual("POST", a);
Assert.AreEqual(action, d["action"]);
Assert.AreEqual(request.ToString(), d["message"]);
var theResponse = new Response
{
RequestIdentifier = request.Identifier
};
return Encoding.UTF8.GetBytes(theResponse.ToString());
});
var connection = new HttpConnection(new Uri(url), factory);
var response = connection.SendMessage(action, request);
Assert.IsInstanceOf<Response>(response);
Assert.AreEqual(request.Identifier, response.RequestIdentifier);
}
示例3: EqualsMatchesRequestWithTheSameIdentifier
public void EqualsMatchesRequestWithTheSameIdentifier()
{
ServerRequest request1 = new ServerRequest();
ServerRequest request2 = new ServerRequest();
request1.Identifier = request2.Identifier;
Assert.IsTrue(request1.Equals(request2));
}
示例4: SendMessageAsyncSendsMessage
public void SendMessageAsyncSendsMessage()
{
var action = "DoSomething";
var request = new ServerRequest
{
ServerName = "TestServer"
};
var url = "http://somewhere/";
var factory = new TestClientFactory((u, a, d) =>
{
Assert.AreEqual(url + "server/TestServer/RawXmlMessage.aspx", u.AbsoluteUri);
Assert.AreEqual("POST", a);
Assert.AreEqual(action, d["action"]);
Assert.AreEqual(request.ToString(), d["message"]);
var theResponse = new Response
{
RequestIdentifier = request.Identifier
};
return Encoding.UTF8.GetBytes(theResponse.ToString());
});
var connection = new HttpConnection(new Uri(url), factory);
var completed = false;
connection.SendMessageCompleted += (o, e) =>
{
completed = true;
Assert.IsFalse(e.Cancelled);
Assert.IsNull(e.Error);
};
connection.SendMessageAsync(action, request);
Assert.IsTrue(completed);
}
示例5: ChannelCanBeSetAndRetrieved
public void ChannelCanBeSetAndRetrieved()
{
var channelInfo = new object();
var message = new ServerRequest();
message.ChannelInformation = channelInfo;
Assert.AreSame(channelInfo, message.ChannelInformation);
}
示例6: FireRequestSending
/// <summary>
/// Fires the <see cref="RequestSending"/> event.
/// </summary>
/// <param name="action">The action that is being sent.</param>
/// <param name="request">The request that is being sent.</param>
protected virtual void FireRequestSending(string action, ServerRequest request)
{
if (RequestSending != null)
{
RequestSending(this, new CommunicationsEventArgs(action, request));
}
}
示例7: InitialiseNewRequestSetsTheDefaultValues
public void InitialiseNewRequestSetsTheDefaultValues()
{
DateTime now = DateTime.Now;
ServerRequest request = new ServerRequest();
Assert.IsFalse(string.IsNullOrEmpty(request.Identifier), "Identifier was not set");
Assert.AreEqual(Environment.MachineName, request.SourceName, "Source name doesn't match the machine name");
Assert.IsTrue((now <= request.Timestamp), "Timestamp was not set");
}
示例8: ConvertXmlToRequestConvertsRequest
public void ConvertXmlToRequestConvertsRequest()
{
var request = new ServerRequest("123456-789");
request.ServerName = "theServer";
var xmlString = request.ToString();
var convertedRequest = XmlConversionUtil.ConvertXmlToRequest(xmlString);
Assert.AreEqual("123456-789", convertedRequest.SessionToken);
Assert.AreEqual("theServer", convertedRequest.ServerName);
}
示例9: InitialiseResponseFromRequestSetsTheDefaultValues
public void InitialiseResponseFromRequestSetsTheDefaultValues()
{
DateTime now = DateTime.Now;
ServerRequest request = new ServerRequest();
ListUsersResponse response = new ListUsersResponse(request);
Assert.AreEqual(ResponseResult.Unknown, response.Result, "Result wasn't set to failure");
Assert.AreEqual(request.Identifier, response.RequestIdentifier, "RequestIdentifier wasn't set to the identifier of the request");
Assert.IsTrue((now <= response.Timestamp), "Timestamp was not set");
}
示例10: InitialiseRequestWithSessionSetsTheCorrectValues
public void InitialiseRequestWithSessionSetsTheCorrectValues()
{
string sessionToken = "the session";
DateTime now = DateTime.Now;
ServerRequest request = new ServerRequest(sessionToken);
Assert.IsFalse(string.IsNullOrEmpty(request.Identifier), "Identifier was not set");
Assert.AreEqual(Environment.MachineName, request.SourceName, "Source name doesn't match the machine name");
Assert.AreEqual(sessionToken, request.SessionToken, "SessionToken doesn't match the input token");
Assert.IsTrue((now <= request.Timestamp), "Timestamp was not set");
}
示例11: ToStringSerialisesDefaultValues
public void ToStringSerialisesDefaultValues()
{
ServerRequest request = new ServerRequest();
string actual = request.ToString();
string expected = string.Format(System.Globalization.CultureInfo.CurrentCulture,"<serverMessage xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
"timestamp=\"{2:yyyy-MM-ddTHH:mm:ss.FFFFFFFzzz}\" identifier=\"{0}\" source=\"{1}\" />",
request.Identifier,
request.SourceName,
request.Timestamp);
Assert.AreEqual(expected, actual);
}
示例12: buildProject
private void buildProject()
{
this._manager = new RemoteCruiseManagerFactory()
.GetCruiseServerClient("tcp://localhost:21234/CruiseManager.rem");
this._project = new ProjectRequest("Edd", this.Name);
this._manager.ForceBuild(this._project);
this._request = new ServerRequest(this._project.SessionToken);
// Write current status
this.progress(String.Empty);
IsRunning = false;
Console.Write("\n\n");
}
示例13: SendMessageEncryptsMessage
public void SendMessageEncryptsMessage()
{
var innerConnection = new TestConnection();
var outerConnection = new EncryptingConnection(innerConnection);
var request = new ServerRequest();
var expectedResponse = new Response(request);
var actionName = "DoSomething";
string iv = null;
string key = null;
innerConnection.SendMessageAction = (a, r) =>
{
Response sendResponse = null;
if (a == "RetrievePublicKey")
{
sendResponse = this.GenerateKeyResponse(r);
}
else if (a == "InitialiseSecureConnection")
{
Assert.IsInstanceOf<LoginRequest>(r);
sendResponse = this.GenerateConnectioResponse(r as LoginRequest, out iv, out key);
}
else if (a == "ProcessSecureRequest")
{
Assert.IsInstanceOf<EncryptedRequest>(r);
var actualRequest = r as EncryptedRequest;
Assert.AreEqual(actionName, actualRequest.Action);
var crypto = new RijndaelManaged();
crypto.Key = Convert.FromBase64String(key);
crypto.IV = Convert.FromBase64String(iv);
var requestData = DecryptMessage(crypto, actualRequest.EncryptedData);
Assert.AreEqual(request.ToString(), requestData);
var encryptedResponse = new EncryptedResponse();
encryptedResponse.Result = ResponseResult.Success;
encryptedResponse.EncryptedData = EncryptMessage(crypto, expectedResponse.ToString());
sendResponse = encryptedResponse;
}
else
{
Assert.Fail("Unknown action: " + a);
}
return sendResponse;
};
var response = outerConnection.SendMessage(actionName, request);
Assert.IsNotNull(response);
Assert.AreEqual(expectedResponse.RequestIdentifier, response.RequestIdentifier);
}
示例14: GetSetAllPropertiesWorks
public void GetSetAllPropertiesWorks()
{
ServerRequest request = new ServerRequest();
request.Identifier = "new id";
Assert.AreEqual("new id", request.Identifier, "Identifier fails the get/set test");
request.ServerName = "new server";
Assert.AreEqual("new server", request.ServerName, "ServerName fails the get/set test");
request.SessionToken = "new session";
Assert.AreEqual("new session", request.SessionToken, "SessionToken fails the get/set test");
request.SourceName = "new source";
Assert.AreEqual("new source", request.SourceName, "SourceName fails the get/set test");
DateTime now = DateTime.Now;
request.Timestamp = now;
Assert.AreEqual(now, request.Timestamp, "Timestamp fails the get/set test");
}
示例15: SendMessage
public Response SendMessage(string action, ServerRequest request)
{
Assert.AreEqual(this.action, action);
Assert.AreEqual(this.message, request.GetType());
if (!string.IsNullOrEmpty(projectName) && (request is ProjectRequest))
{
Assert.AreEqual(this.projectName, (request as ProjectRequest).ProjectName);
}
if (response == null)
{
Response result = new Response(request);
result.Result = ResponseResult.Success;
return result;
}
else
{
return response;
}
}