public void SuccessTest() { string xml = @"<?xml version=""1.0"" encoding=""utf-8""?> <response> <acknowledgement> <status>success</status> </acknowledgement> <control> <status>success</status> <senderid>testsenderid</senderid> <controlid>ControlIdHere</controlid> <uniqueid>false</uniqueid> <dtdversion>3.0</dtdversion> </control> </response>"; Stream stream = new MemoryStream(); StreamWriter streamWriter = new StreamWriter(stream); streamWriter.Write(xml); streamWriter.Flush(); stream.Position = 0; AsynchronousResponse response = new AsynchronousResponse(stream); Assert.AreEqual("success", response.Acknowledgement.Status); }
public async Task ExecuteAsynchronousMissingPolicyIdTest() { SdkConfig config = new SdkConfig() { SenderId = "testsenderid", SenderPassword = "******", SessionId = "testsession..", }; Content content = new Content(); RequestHandler requestHandler = new RequestHandler(config); AsynchronousResponse response = await requestHandler.ExecuteAsynchronous(config, content); }
protected async Task <AsynchronousResponse> ExecuteAsync( Content contentBlock, string asyncPolicyId, bool transaction, string requestControlId, bool uniqueFunctionControlIds, SdkConfig config ) { SdkConfig sessionConfig = SessionConfig(); if (String.IsNullOrWhiteSpace(config.PolicyId)) { config.PolicyId = asyncPolicyId; } if (!String.IsNullOrWhiteSpace(sessionConfig.SenderId)) { config.SenderId = sessionConfig.SenderId; } if (!String.IsNullOrWhiteSpace(sessionConfig.SenderPassword)) { config.SenderPassword = sessionConfig.SenderPassword; } if (!String.IsNullOrWhiteSpace(sessionConfig.EndpointUrl)) { config.EndpointUrl = sessionConfig.EndpointUrl; } if (!String.IsNullOrWhiteSpace(sessionConfig.SessionId)) { config.SessionId = sessionConfig.SessionId; } config.Logger = config.Logger != null ? config.Logger : sessionConfig.Logger; config.LogFormatter = config.LogFormatter != null ? config.LogFormatter : sessionConfig.LogFormatter; config.LogLevel = config.LogLevel != null ? config.LogLevel : sessionConfig.LogLevel; config.Transaction = transaction; config.ControlId = requestControlId; config.UniqueId = uniqueFunctionControlIds; RequestHandler requestHandler = new RequestHandler(config); AsynchronousResponse response = await requestHandler.ExecuteAsynchronous(config, contentBlock); return(response); }
public async Task MockExecuteAsynchronousTest() { string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?> <response> <acknowledgement> <status>success</status> </acknowledgement> <control> <status>success</status> <senderid>testsenderid</senderid> <controlid>requestUnitTest</controlid> <uniqueid>false</uniqueid> <dtdversion>3.0</dtdversion> </control> </response>"; HttpResponseMessage mockResponse = new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.OK, Content = new StringContent(xml) }; List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage> { mockResponse, }; MockHandler mockHandler = new MockHandler(mockResponses); SdkConfig config = new SdkConfig() { SenderId = "testsenderid", SenderPassword = "******", SessionId = "testsession..", PolicyId = "policyid321", ControlId = "requestUnitTest", MockHandler = mockHandler, }; Content content = new Content(); RequestHandler requestHandler = new RequestHandler(config); AsynchronousResponse response = await requestHandler.ExecuteAsynchronous(config, content); Assert.IsInstanceOfType(response, typeof(AsynchronousResponse)); Assert.AreEqual("testsenderid", response.Control.SenderId); }
public async Task ExecuteAsynchronousTest() { string xml = @"<?xml version=""1.0"" encoding=""utf-8""?> <response> <acknowledgement> <status>success</status> </acknowledgement> <control> <status>success</status> <senderid>testsenderid</senderid> <controlid>requestUnitTest</controlid> <uniqueid>false</uniqueid> <dtdversion>3.0</dtdversion> </control> </response>"; HttpResponseMessage mockResponse1 = new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.OK, Content = new StringContent(xml) }; List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage> { mockResponse1, }; MockHandler mockHandler = new MockHandler(mockResponses); SdkConfig config = new SdkConfig { MockHandler = mockHandler, }; Content content = new Content(); content.Add(new ApiSessionCreate("func1UnitTest")); AsynchronousResponse response = await client.ExecuteAsync(content, "asyncPolicyId", false, "requestUnitTest", false, config); Assert.AreEqual("requestUnitTest", response.Control.ControlId); }