diff --git a/CHANGELOG b/CHANGELOG index 6476efaa..ec05e2d6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ = Worldpay CNP CHANGELOG +==Version 12.15.1 (October 7, 2020) +* Feature: Added maxConnections config parameter to set the maximum number of http connections (defaults to ServicePointManager.DefaultConnectionLimit) +* Change: Propagated changes from 12.7.5-12.7.6, with some changes +* Change: The first CnpOnline object's config will now determine the proxy and timeout for the lifetime of the application +* BugFix: Tls 1.2 now the only available online encryption, specified for cnp-related connections only + ==Version 12.15.0 (October 7, 2020) * Feature: Added AuthenticationShopperID to cardTokenType * Feature: Added copayAmount to healthcareAmounts @@ -68,7 +74,12 @@ ==Version 12.8.0 (June 20, 2019) * Feature: Added new tokenURL element - + +==Version 12.7.6 (September 3, 2020) +* Feature: merchantId field added to CnpOnline class to allow changing merchantIds with same CnpOnline instance. +* Feature: keepAlive setting added to config for keeping the Async Http Request Alive +* BugFix: communication field is made static in CnpOnline to limit initializations + ==Version 12.7.5 (July 17, 2019) * BugFix: Refactor config code to limit direct property usage diff --git a/CnpSdkForNet/CnpSdkForNet/CnpBatch.cs b/CnpSdkForNet/CnpSdkForNet/CnpBatch.cs index 749e857b..a65c3b4d 100644 --- a/CnpSdkForNet/CnpSdkForNet/CnpBatch.cs +++ b/CnpSdkForNet/CnpSdkForNet/CnpBatch.cs @@ -85,7 +85,7 @@ public cnpRequest(Dictionary config) // private void initializeRequest() { - communication = new Communications(); + communication = new Communications(config); authentication = new authentication(); authentication.user = config["username"]; @@ -212,7 +212,7 @@ public string sendToCnp() PgpHelper.EncryptFile(requestFilePath, finalRequestFilePath, vantivPublicKeyId); } - communication.FtpDropOff(batchRequestDir, Path.GetFileName(finalRequestFilePath), config); + communication.FtpDropOff(batchRequestDir, Path.GetFileName(finalRequestFilePath)); return Path.GetFileName(finalRequestFilePath); } @@ -241,7 +241,7 @@ public cnpResponse receiveFromCnp(string batchFileName) Path.Combine(batchResponseDir, batchFileName); cnpFile.createDirectory(finalResponseFilePath); } - communication.FtpPickUp(finalResponseFilePath, config, batchFileName); + communication.FtpPickUp(finalResponseFilePath, batchFileName); if ("true".Equals(useEncryption)) { diff --git a/CnpSdkForNet/CnpSdkForNet/CnpOnline.cs b/CnpSdkForNet/CnpSdkForNet/CnpOnline.cs index 2970fd7d..42272933 100644 --- a/CnpSdkForNet/CnpSdkForNet/CnpOnline.cs +++ b/CnpSdkForNet/CnpSdkForNet/CnpOnline.cs @@ -9,7 +9,6 @@ namespace Cnp.Sdk { - // Represent an online request. // Defining all transactions supported for online processing. @@ -17,31 +16,17 @@ public class CnpOnline : ICnpOnline { // Configuration object containing credentials and settings. private Dictionary _config; - // + + // The object used for communicating with the server private Communications _communication; + // exposed merchantId for organizations with multiple Merchant Ids. + private string _merchantId; + /** * Construct a Cnp online using the configuration specified in CnpSdkForNet.dll.config */ - public CnpOnline() - { - ConfigManager configManager = new ConfigManager(); - _config = configManager.getConfig(); - - //_config["url"] = Properties.Settings.Default.url; - //_config["reportGroup"] = Properties.Settings.Default.reportGroup; - //_config["username"] = Properties.Settings.Default.username; - //_config["printxml"] = Properties.Settings.Default.printxml; - //_config["timeout"] = Properties.Settings.Default.timeout; - //_config["proxyHost"] = Properties.Settings.Default.proxyHost; - //_config["merchantId"] = Properties.Settings.Default.merchantId; - //_config["password"] = Properties.Settings.Default.password; - //_config["proxyPort"] = Properties.Settings.Default.proxyPort; - //_config["logFile"] = Properties.Settings.Default.logFile; - //_config["neuterAccountNums"] = Properties.Settings.Default.neuterAccountNums; - _communication = new Communications(); - - } + public CnpOnline() : this(new ConfigManager().getConfig()) { } /** * Construct a CnpOnline specifying the configuration in code. This should be used by integration that have another way @@ -58,24 +43,42 @@ public CnpOnline() * proxyHost * proxyPort * printxml (possible values "true" and "false" - defaults to false) + * maxConnections (max amount of connections used for HTTP requests) + * + * NOTE: The config of the first CnpOnline object created will determine the following + * for the entire lifespan of the application: + * - proxyHost + * - proxyPort + * - timeout + * - maxConnections + * These values *cannot* be changed for the lifetime of the application */ public CnpOnline(Dictionary config) { - this._config = config; - _communication = new Communications(); + _config = config; + SetCommunication(new Communications(_config)); } - public event EventHandler HttpAction + public void SetCommunication(Communications communication) { - add { _communication.HttpAction += value; } - remove { _communication.HttpAction -= value; } + _communication = communication; } - public void SetCommunication(Communications communication) + public string GetMerchantId() { - this._communication = communication; + return _merchantId; + } + + public void SetMerchantId(string merchantId) + { + _merchantId = merchantId; + } + + public event EventHandler HttpAction + { + add { _communication.HttpAction += value; } + remove { _communication.HttpAction -= value; } } - public Task AuthorizeAsync(authorization auth, CancellationToken cancellationToken) { @@ -1022,8 +1025,8 @@ public Task CustomerDebitAsync(customerDebit customerDebi private cnpOnlineRequest CreateCnpOnlineRequest() { var request = new cnpOnlineRequest(); - request.merchantId = _config["merchantId"]; request.merchantSdk = "DotNet;" + CnpVersion.CurrentCNPSDKVersion; + request.merchantId = _merchantId ?? _config["merchantId"]; var authentication = new authentication(); authentication.password = _config["password"]; authentication.user = _config["username"]; @@ -1034,7 +1037,7 @@ private cnpOnlineRequest CreateCnpOnlineRequest() private cnpOnlineResponse SendToCnp(cnpOnlineRequest request) { var xmlRequest = request.Serialize(); - var xmlResponse = _communication.HttpPost(xmlRequest, _config); + var xmlResponse = _communication.HttpPost(xmlRequest); if (xmlResponse == null) { throw new WebException("Could not retrieve response from server for given request"); @@ -1086,7 +1089,7 @@ private async Task SendRequestAsync(Func getResponse private async Task SendToCnpAsync(cnpOnlineRequest request, CancellationToken cancellationToken) { string xmlRequest = request.Serialize(); - string xmlResponse = await _communication.HttpPostAsync(xmlRequest, _config, cancellationToken).ConfigureAwait(false); + string xmlResponse = await _communication.HttpPostAsync(xmlRequest, cancellationToken).ConfigureAwait(false); return DeserializeResponse(xmlResponse); } diff --git a/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj b/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj index 465cb1f7..c4f472ea 100644 --- a/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj +++ b/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj @@ -3,7 +3,7 @@ netstandard2.0 true dotNetSDKKey.snk - 12.15.0 + 12.15.1 Vantiv.CnpSdkForNet Worldpay Copyright © Worldpay 2020 diff --git a/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs b/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs index 3a10cff8..d07cd54f 100644 --- a/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs +++ b/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs @@ -9,6 +9,6 @@ namespace Cnp.Sdk public class CnpVersion { public const String CurrentCNPXMLVersion = "12.15"; - public const String CurrentCNPSDKVersion = "12.15.0"; + public const String CurrentCNPSDKVersion = "12.15.1"; } } diff --git a/CnpSdkForNet/CnpSdkForNet/Communications.cs b/CnpSdkForNet/CnpSdkForNet/Communications.cs index 5ad8a856..e7c1c008 100644 --- a/CnpSdkForNet/CnpSdkForNet/Communications.cs +++ b/CnpSdkForNet/CnpSdkForNet/Communications.cs @@ -4,8 +4,11 @@ using System.Diagnostics; using System.Globalization; using System.Net; +using System.Net.Http; using System.Net.Security; +using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; +using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -15,32 +18,115 @@ namespace Cnp.Sdk { + /// + /// Communications handles outbound communications with the API + /// There is a component of this class that deals with HTTP requests (using HttpClient) and one that deals with SFTP + /// public class Communications { + /// + /// Locking object so that writing logs are thread safe + /// private static readonly object SynLock = new object(); - public static string ContentTypeTextXmlUTF8 = "text/xml; charset=UTF-8"; public event EventHandler HttpAction; + /// + /// Client for communicating with the APIs through HTTP + /// _client is static so it will only be created once, as recommended in the documentation + /// + private static HttpClient _client; + + /// + /// The configuration dictionary containing logging, proxy, and other various properties + /// + private readonly Dictionary _config; + + /// + /// The main constructor, which initializes the config and HttpClient + /// + /// + public Communications(Dictionary config = null) + { + _config = config ?? new ConfigManager().getConfig(); - private void OnHttpAction(RequestType requestType, string xmlPayload, bool neuterAccNums, bool neuterCreds) + // On the first initialization of this class, initialize the HttpClient based on the given config + if (_client == null) + { + InitializeHttpClient(); + } + } + + /// + /// A no-arg constructor that simply calls the main constructor, primarily used for mocking in tests + /// This constructor serves no other purpose than to keep the tests passing + /// + public Communications() : this(null) { } + + /// + /// Initializes the http client based on the config + /// + private void InitializeHttpClient() { - if (HttpAction != null) + // The handler specifies several fields we need that cannot be directly set on the HttpClient + var handler = new HttpClientHandler {SslProtocols = SslProtocols.Tls12}; + + // Set the maximum connections for the client, if specified + if (IsValidConfigValueSet("maxConnections")) { - if (neuterAccNums) + int.TryParse(_config["maxConnections"], out var maxConnections); + if (maxConnections > 0) { - NeuterXml(ref xmlPayload); + handler.MaxConnectionsPerServer = maxConnections; } + } - if (neuterCreds) + // Configure the client to use the proxy, if specified + if (IsProxyOn()) + { + handler.Proxy = new WebProxy(_config["proxyHost"], int.Parse(_config["proxyPort"])) { - NeuterUserCredentials(ref xmlPayload); - } + BypassProxyOnLocal = true + }; + handler.UseProxy = true; + } - HttpAction(this, new HttpActionEventArgs(requestType, xmlPayload)); + // Now that the handler is set up, configure any remaining fields on the HttpClient + _client = new HttpClient(handler) {BaseAddress = new Uri(_config["url"])}; + + // Set the timeout for the client, if specified + if (_config.ContainsKey("timeout")) + { + // Read timeout from config and default to 60000 (1 minute) if it cannot be parsed + var timeoutInMillis = int.TryParse(_config["timeout"], out var temp) ? temp : 60000; + _client.Timeout = TimeSpan.FromMilliseconds(timeoutInMillis); } } + /// + /// DO NOT USE THIS METHOD UNLESS YOU KNOW WHAT YOU ARE DOING! + /// Disposes the HttpClient, allowing for the initialization of a new one. + /// This was created for use in testing, and should not be used normally unless a configuration value changed. + /// If a configuration value changed, you will need to create a new Communications object with the new config + /// immediately for the effects to take place (applies to url, proxy, maxConnections, and timeout settings) + /// NPEs may be thrown after calling this method and before creating a new Communications--be warned. + /// As such, this method is extremely dangerous in a multi-threaded environment. + /// + public static void DisposeHttpClient() + { + _client?.Dispose(); + _client = null; + } + + private void OnHttpAction(RequestType requestType, string xmlPayload) + { + if (HttpAction == null) return; + + NeuterXml(ref xmlPayload); + NeuterUserCredentials(ref xmlPayload); + + HttpAction(this, new HttpActionEventArgs(requestType, xmlPayload)); + } public static bool ValidateServerCertificate( object sender, @@ -53,13 +139,20 @@ public static bool ValidateServerCertificate( Console.WriteLine("Certificate error: {0}", sslPolicyErrors); - // Do not allow this client to communicate with unauthenticated servers. + // Do not allow this client to communicate with unauthenticated servers. return false; } + /// + /// Obfuscates account information in the XML, only if the config value specifies to do so + /// + /// the XML to obfuscate public void NeuterXml(ref string inputXml) { - + var neuterAccountNumbers = + _config.ContainsKey("neuterAccountNums") && "true".Equals(_config["neuterAccountNums"]); + if (!neuterAccountNumbers) return; + const string pattern1 = "(?i).*?"; const string pattern2 = "(?i).*?"; const string pattern3 = "(?i).*?"; @@ -75,8 +168,15 @@ public void NeuterXml(ref string inputXml) inputXml = rgx4.Replace(inputXml, "xxxxxxxxxxxxxxxx"); } + /// + /// Obfuscates user credentials in the XML, only if the config value specifies to do so + /// + /// the XML to obfuscate public void NeuterUserCredentials(ref string inputXml) { + var neuterUserCredentials = + _config.ContainsKey("neuterUserCredentials") && "true".Equals(_config["neuterUserCredentials"]); + if (!neuterUserCredentials) return; const string pattern1 = "(?i).*?"; const string pattern2 = "(?i).*>"; @@ -87,18 +187,18 @@ public void NeuterUserCredentials(ref string inputXml) inputXml = rgx2.Replace(inputXml, "xxxxxxxx"); } - public void Log(string logMessage, string logFile, bool neuterAccNums, bool neuterCreds) + /// + /// Logs the specified logMessage to the logFile + /// + /// The message to log + /// The file to write the message to + public void Log(string logMessage, string logFile) { lock (SynLock) { - if (neuterAccNums) - { - NeuterXml(ref logMessage); - } - if (neuterCreds) - { - NeuterUserCredentials(ref logMessage); - } + NeuterXml(ref logMessage); + NeuterUserCredentials(ref logMessage); + using (var logWriter = new StreamWriter(logFile, true)) { var time = DateTime.Now; @@ -107,316 +207,101 @@ public void Log(string logMessage, string logFile, bool neuterAccNums, bool neut } } } - - public HttpWebRequest CreateWebRequest(string xmlRequest,Dictionary config) - { - // Get the log file. - string logFile = null; - if (IsValidConfigValueSet(config, "logFile")) - { - logFile = config["logFile"]; - } - - // Get the rest of the configuration values. - var requestUrl = config["url"]; - var printXml = false; - var neuterAccountNumbers = false; - var neuterUserCredentials = false; - if (config.ContainsKey("neuterAccountNums")) - { - neuterAccountNumbers = ("true".Equals(config["neuterAccountNums"])); - } - if (config.ContainsKey("neuterUserCredentials")) - { - neuterUserCredentials = ("true".Equals(config["neuterUserCredentials"])); - } - if (config.ContainsKey("printxml")) - { - printXml = ("true".Equals(config["printxml"])); - } - - // Get the request target information. - ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11; - var request = (HttpWebRequest)WebRequest.Create(requestUrl); - // Output the request and log file. + /// + /// Sends a POST request with the given XML to the API, asynchronously + /// Prefer the use of this method over HttpPost + /// + /// The XML to send to the API + /// + /// The XML response on success, null otherwise + public async Task HttpPostAsync(string xmlRequest, CancellationToken cancellationToken) + { + // First, read values from the config that we need that relate to logging + _config.TryGetValue("logFile", out var logFile); + var printXml = _config.ContainsKey("printxml") && "true".Equals(_config["printxml"]); + + // Log any data to the appropriate places, only if we need to if (printXml) { Console.WriteLine(xmlRequest); Console.WriteLine(logFile); } - - // Log the request. if (logFile != null) { - this.Log(xmlRequest,logFile, neuterAccountNumbers,neuterUserCredentials); - } - - // Set up the request. - request.ContentType = ContentTypeTextXmlUTF8; - request.Method = "POST"; - request.ServicePoint.MaxIdleTime = 8000; - request.ServicePoint.Expect100Continue = false; - request.KeepAlive = true; - if (IsProxyOn(config)) - { - var proxy = new WebProxy(config["proxyHost"], int.Parse(config["proxyPort"])) - { - BypassProxyOnLocal = true - }; - request.Proxy = proxy; - } - - // Set the timeout (only effective for non-async requests. - if (config.ContainsKey("timeout")) { - try { - request.Timeout = Convert.ToInt32(config["timeout"]); - } - catch (FormatException e) { - // If timeout setting contains non-numeric - // characters, we will fall back to 1 minute - // default timeout. - request.Timeout = 60000; - } + Log(xmlRequest, logFile); } - - // Invoke the event. - this.OnHttpAction(Communications.RequestType.Request,xmlRequest,neuterAccountNumbers,neuterUserCredentials); - // Return the request. - return request; - } - - public virtual Task HttpPostAsync(string xmlRequest, Dictionary config, CancellationToken cancellationToken) - { - return HttpPostCoreAsync(xmlRequest, config, cancellationToken); - } - - private async Task HttpPostCoreAsync(string xmlRequest, Dictionary config, CancellationToken cancellationToken) - { - string logFile = null; - var printXml = false; - var neuterAccountNumbers = false; - var neuterUserCredentials = false; - if (IsValidConfigValueSet(config, "logFile")) - { - logFile = config["logFile"]; - } - if (config.ContainsKey("neuterAccountNums")) - { - neuterAccountNumbers = ("true".Equals(config["neuterAccountNums"])); - } - if (config.ContainsKey("neuterUserCredentials")) - { - neuterUserCredentials = ("true".Equals(config["neuterUserCredentials"])); - } - if (config.ContainsKey("printxml")) - { - printXml = ("true".Equals(config["printxml"])); - } - - // submit http request - var request = this.CreateWebRequest(xmlRequest, config); - using (var writer = new StreamWriter(await request.GetRequestStreamAsync().ConfigureAwait(false))) - { - writer.Write(xmlRequest); - } - - // read response - string xmlResponse = null; - var response = await request.GetResponseAsync().ConfigureAwait(false); + // Now that we have gotten the values for logging from the config, we need to actually send the request try { - using (var reader = new StreamReader(response.GetResponseStream())) - { - xmlResponse = (await reader.ReadToEndAsync().ConfigureAwait(false)).Trim(); - } + OnHttpAction(RequestType.Request, xmlRequest); + var xmlContent = new StringContent(xmlRequest, Encoding.UTF8, "application/xml"); + var response = await _client.PostAsync(_config["url"], xmlContent, cancellationToken); + var xmlResponse = await response.Content.ReadAsStringAsync(); + OnHttpAction(RequestType.Response, xmlResponse); + if (printXml) { Console.WriteLine(xmlResponse); } - - OnHttpAction(RequestType.Response, xmlResponse, neuterAccountNumbers, neuterUserCredentials); - - //log response if (logFile != null) { - Log(xmlResponse, logFile, neuterAccountNumbers, neuterUserCredentials); + Log(xmlResponse, logFile); } - }catch (WebException we) + + return xmlResponse; + } + catch (Exception) { - + return null; } - - return xmlResponse; } - - public bool IsProxyOn(Dictionary config) + + /// + /// Sends a POST request synchronously to the API. Prefer the async variant of this method when possible. + /// Eventually, this method and all other sync-based methods should be deprecated to match C# style + /// This is only kept now for backwards compatibility + /// + /// The XML to send to the API + /// The XML response as a string on success, or null otherwise + public virtual string HttpPost(string xmlRequest) { - return IsValidConfigValueSet(config, "proxyHost") && IsValidConfigValueSet(config, "proxyPort"); + var source = new CancellationTokenSource(); + var asyncTask = Task.Run(() => HttpPostAsync(xmlRequest, source.Token), source.Token); + asyncTask.Wait(source.Token); + return asyncTask.Result; } - public bool IsValidConfigValueSet(Dictionary config, string propertyName) + /// + /// Determines if the proxy is on based on the object's configuration + /// + /// Whether or not a web proxy should be used + public bool IsProxyOn() { - return config != null && config.ContainsKey(propertyName) && !String.IsNullOrEmpty(config[propertyName]); + return IsValidConfigValueSet("proxyHost") && IsValidConfigValueSet("proxyPort"); } - public virtual string HttpPost(string xmlRequest, Dictionary config) + /// + /// Determines whether the specified parameter is properly set in the configuration + /// + /// The property to check for in the config + /// Whether or not propertyName is properly set in _config + public bool IsValidConfigValueSet(string propertyName) { - string logFile = null; - var printXml = false; - var neuterAccountNumbers = false; - var neuterUserCredentials = false; - if (IsValidConfigValueSet(config, "logFile")) - { - logFile = config["logFile"]; - } - if (config.ContainsKey("neuterAccountNums")) - { - neuterAccountNumbers = ("true".Equals(config["neuterAccountNums"])); - } - if (config.ContainsKey("neuterUserCredentials")) - { - neuterUserCredentials = ("true".Equals(config["neuterUserCredentials"])); - } - if (config.ContainsKey("printxml")) - { - printXml = ("true".Equals(config["printxml"])); - } - - // submit http request - var request = this.CreateWebRequest(xmlRequest, config); - - // submit http request - using (var writer = new StreamWriter(request.GetRequestStream())) - { - writer.Write(xmlRequest); - } - - // read response - string xmlResponse = null; - try - { - var resp = request.GetResponse(); - if (resp == null) - { - return null; - } - HttpWebResponse httpResp = (HttpWebResponse)resp; - - using (var reader = new StreamReader(resp.GetResponseStream())) - { - xmlResponse = reader.ReadToEnd().Trim(); - } - if (printXml) - { - Console.WriteLine(xmlResponse); - } - - OnHttpAction(RequestType.Response, xmlResponse, neuterAccountNumbers, neuterUserCredentials); - - //log response - if (logFile != null) - { - Log(xmlResponse, logFile, neuterAccountNumbers, neuterUserCredentials); - } - } catch (WebException we) - { - - } - - return xmlResponse; + return _config.ContainsKey(propertyName) && !string.IsNullOrEmpty(_config[propertyName]); } - - - //public virtual string SocketStream(string xmlRequestFilePath, string xmlResponseDestinationDirectory, Dictionary config) - //{ - // var url = config["onlineBatchUrl"]; - // var port = int.Parse(config["onlineBatchPort"]); - // TcpClient tcpClient; - // SslStream sslStream; - - // try - // { - // tcpClient = new TcpClient(url, port); - // sslStream = new SslStream(tcpClient.GetStream(), false, ValidateServerCertificate, null); - // } - // catch (SocketException e) - // { - // throw new CnpOnlineException("Error establishing a network connection", e); - // } - - // try - // { - // sslStream.AuthenticateAsClient(url); - // } - // catch (AuthenticationException e) - // { - // tcpClient.Close(); - // throw new CnpOnlineException("Error establishing a network connection - SSL Authencation failed", e); - // } - - // if ("true".Equals(config["printxml"])) - // { - // Console.WriteLine("Using XML File: " + xmlRequestFilePath); - // } - - // using (var readFileStream = new FileStream(xmlRequestFilePath, FileMode.Open)) - // { - // var bytesRead = -1; - - // do - // { - // var byteBuffer = new byte[1024 * sizeof(char)]; - // bytesRead = readFileStream.Read(byteBuffer, 0, byteBuffer.Length); - - // sslStream.Write(byteBuffer, 0, bytesRead); - // sslStream.Flush(); - // } while (bytesRead != 0); - // } - - // var batchName = Path.GetFileName(xmlRequestFilePath); - // var destinationDirectory = Path.GetDirectoryName(xmlResponseDestinationDirectory); - // if (!Directory.Exists(destinationDirectory)) - // { - // if (destinationDirectory != null) Directory.CreateDirectory(destinationDirectory); - // } - - // if ("true".Equals(config["printxml"])) - // { - // Console.WriteLine("Writing to XML File: " + xmlResponseDestinationDirectory + batchName); - // } - - // using (var writeFileStream = new FileStream(xmlResponseDestinationDirectory + batchName, FileMode.Create)) - // { - // int bytesRead; - - // do - // { - // var byteBuffer = new byte[1024 * sizeof(char)]; - // bytesRead = sslStream.Read(byteBuffer, 0, byteBuffer.Length); - - // writeFileStream.Write(byteBuffer, 0, bytesRead); - // } while (bytesRead > 0); - // } - - // tcpClient.Close(); - // sslStream.Close(); - - // return xmlResponseDestinationDirectory + batchName; - //} - - public virtual void FtpDropOff(string fileDirectory, string fileName, Dictionary config) + public virtual void FtpDropOff(string fileDirectory, string fileName) { SftpClient sftpClient; - var url = config["sftpUrl"]; - var username = config["sftpUsername"]; - var password = config["sftpPassword"]; + var url = _config["sftpUrl"]; + var username = _config["sftpUsername"]; + var password = _config["sftpPassword"]; var filePath = Path.Combine(fileDirectory, fileName); - var printxml = config["printxml"] == "true"; + var printxml = _config["printxml"] == "true"; if (printxml) { Console.WriteLine("Sftp Url: " + url); @@ -531,20 +416,19 @@ public virtual void FtpPoll(string fileName, int timeout, Dictionary config, string fileName) + public virtual void FtpPickUp(string destinationFilePath, string fileName) { SftpClient sftpClient; - var printxml = config["printxml"] == "true"; - - var url = config["sftpUrl"]; - var username = config["sftpUsername"]; - var password = config["sftpPassword"]; + var printxml = _config["printxml"] == "true"; + var url = _config["sftpUrl"]; + var username = _config["sftpUsername"]; + var password = _config["sftpPassword"]; sftpClient = new SftpClient(url, username, password); @@ -600,19 +484,17 @@ public HttpActionEventArgs(RequestType requestType, string xmlPayload) XmlPayload = xmlPayload; } } - + private String getSftpFileAttributes(SftpFileAttributes sftpAttrs) { String permissions = sftpAttrs.GetBytes().ToString(); return "Permissions: " + permissions - + " | UserID: " + sftpAttrs.UserId - + " | GroupID: " + sftpAttrs.GroupId - + " | Size: " + sftpAttrs.Size + + " | UserID: " + sftpAttrs.UserId + + " | GroupID: " + sftpAttrs.GroupId + + " | Size: " + sftpAttrs.Size + " | LastEdited: " + sftpAttrs.LastWriteTime.ToString(); } - - public struct SshConnectionInfo { public string Host; diff --git a/CnpSdkForNet/CnpSdkForNet/ConfigManager.cs b/CnpSdkForNet/CnpSdkForNet/ConfigManager.cs index e3ccf081..85a38a7a 100644 --- a/CnpSdkForNet/CnpSdkForNet/ConfigManager.cs +++ b/CnpSdkForNet/CnpSdkForNet/ConfigManager.cs @@ -12,76 +12,36 @@ public Dictionary getConfig() return _config; } - public ConfigManager() + public ConfigManager() : this(new Dictionary { - _config = new Dictionary(); - _config["url"] = Properties.Settings.Default.url; - _config["reportGroup"] = Properties.Settings.Default.reportGroup; - _config["username"] = Properties.Settings.Default.username; - _config["printxml"] = Properties.Settings.Default.printxml; - _config["timeout"] = Properties.Settings.Default.timeout; - _config["proxyHost"] = Properties.Settings.Default.proxyHost; - _config["merchantId"] = Properties.Settings.Default.merchantId; - _config["password"] = Properties.Settings.Default.password; - _config["proxyPort"] = Properties.Settings.Default.proxyPort; - _config["logFile"] = Properties.Settings.Default.logFile; - _config["neuterAccountNums"] = Properties.Settings.Default.neuterAccountNums; - _config["sftpUrl"] = Properties.Settings.Default.sftpUrl; - _config["sftpUsername"] = Properties.Settings.Default.sftpUsername; - _config["sftpPassword"] = Properties.Settings.Default.sftpPassword; - _config["onlineBatchUrl"] = Properties.Settings.Default.onlineBatchUrl; - _config["onlineBatchPort"] = Properties.Settings.Default.onlineBatchPort; - _config["requestDirectory"] = Properties.Settings.Default.requestDirectory; - _config["responseDirectory"] = Properties.Settings.Default.responseDirectory; - _config["useEncryption"] = Properties.Settings.Default.useEncryption; - _config["vantivPublicKeyId"] = Properties.Settings.Default.vantivPublicKeyId; - _config["pgpPassphrase"] = Properties.Settings.Default.pgpPassphrase; - _config["neuterUserCredentials"] = Properties.Settings.Default.neuterUserCredentials; - - - - } + ["url"] = Properties.Settings.Default.url, + ["reportGroup"] = Properties.Settings.Default.reportGroup, + ["username"] = Properties.Settings.Default.username, + ["printxml"] = Properties.Settings.Default.printxml, + ["timeout"] = Properties.Settings.Default.timeout, + ["proxyHost"] = Properties.Settings.Default.proxyHost, + ["merchantId"] = Properties.Settings.Default.merchantId, + ["password"] = Properties.Settings.Default.password, + ["proxyPort"] = Properties.Settings.Default.proxyPort, + ["logFile"] = Properties.Settings.Default.logFile, + ["neuterAccountNums"] = Properties.Settings.Default.neuterAccountNums, + ["sftpUrl"] = Properties.Settings.Default.sftpUrl, + ["sftpUsername"] = Properties.Settings.Default.sftpUsername, + ["sftpPassword"] = Properties.Settings.Default.sftpPassword, + ["onlineBatchUrl"] = Properties.Settings.Default.onlineBatchUrl, + ["onlineBatchPort"] = Properties.Settings.Default.onlineBatchPort, + ["requestDirectory"] = Properties.Settings.Default.requestDirectory, + ["responseDirectory"] = Properties.Settings.Default.responseDirectory, + ["useEncryption"] = Properties.Settings.Default.useEncryption, + ["vantivPublicKeyId"] = Properties.Settings.Default.vantivPublicKeyId, + ["pgpPassphrase"] = Properties.Settings.Default.pgpPassphrase, + ["neuterUserCredentials"] = Properties.Settings.Default.neuterUserCredentials, + ["maxConnections"] = Properties.Settings.Default.maxConnections + }) { } public ConfigManager(Dictionary config) { _config = config; } - - //public void configureConfig() - //{ - // Console.Write("Please input the URL for online transactions (ex: https://www.testantivcnp.com/sandbox/communicator/online):"); - // string url = Console.ReadLine(); - // setProperty("url", url); - // Console.Write("reportGroup: "); - // string reportGroup = Console.ReadLine(); - // setProperty("reportGroup", reportGroup); - // Console.Write("Please input your presenter user name: "); - // string username = Console.ReadLine(); - // setProperty("username", username); - // Console.Write("printxml: "); - // string printxml = Console.ReadLine(); - // setProperty("printxml", printxml); - // Console.Write("timeout: "); - // string timeout = Console.ReadLine(); - // setProperty("timeout", timeout); - // Console.Write(" - //} - - //private void setProperty(string property, string val) - //{ - // if (val.ToLower() == "t" || val.ToLower() == "true") - // { - // _config[property] = "true"; - // } - // else if (val.ToLower() == "f" || val.ToLower() == "false") - // { - // _config[property] = "false"; - // } - // else if (val != "") - // { - // _config[property] = val; - // } - //} - } } diff --git a/CnpSdkForNet/CnpSdkForNet/Properties/Settings.Designer.cs b/CnpSdkForNet/CnpSdkForNet/Properties/Settings.Designer.cs index fae06dac..aedabeac 100644 --- a/CnpSdkForNet/CnpSdkForNet/Properties/Settings.Designer.cs +++ b/CnpSdkForNet/CnpSdkForNet/Properties/Settings.Designer.cs @@ -181,13 +181,13 @@ public string password { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("true")] - public string keepAlive { + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string maxConnections { get { - return ((string)(this["keepAlive"])); + return ((string)(this["maxConnections"])); } set { - this["keepAlive"] = value; + this["maxConnections"] = value; } } diff --git a/CnpSdkForNet/CnpSdkForNet/Properties/Settings.settings b/CnpSdkForNet/CnpSdkForNet/Properties/Settings.settings index 6484b4c7..78718027 100644 --- a/CnpSdkForNet/CnpSdkForNet/Properties/Settings.settings +++ b/CnpSdkForNet/CnpSdkForNet/Properties/Settings.settings @@ -41,8 +41,8 @@ V2b9F4k7 - - true + + true diff --git a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert1Base.cs b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert1Base.cs index c5382fe7..c49076b1 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert1Base.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert1Base.cs @@ -31,6 +31,11 @@ public void SetUp() cnp = new CnpOnline(configManager.getConfig()); } + [OneTimeTearDown] + public void Dispose() + { + Communications.DisposeHttpClient(); + } [Test] public void Test1Auth() diff --git a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert2AuthEnhanced.cs b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert2AuthEnhanced.cs index 806ef65a..857298c6 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert2AuthEnhanced.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert2AuthEnhanced.cs @@ -32,6 +32,12 @@ public void SetUp() cnp = new CnpOnline(configManager.getConfig()); } + [OneTimeTearDown] + public void Dispose() + { + Communications.DisposeHttpClient(); + } + [Test] public void Test14() { diff --git a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert3AuthReversal.cs b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert3AuthReversal.cs index 9c4003ad..9bc2d740 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert3AuthReversal.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert3AuthReversal.cs @@ -31,6 +31,12 @@ public void SetUp() cnp = new CnpOnline(configManager.getConfig()); } + [OneTimeTearDown] + public void Dispose() + { + Communications.DisposeHttpClient(); + } + [Test] public void Test32() { diff --git a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert4Echeck.cs b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert4Echeck.cs index 02801035..c34cf7f1 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert4Echeck.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert4Echeck.cs @@ -31,6 +31,12 @@ public void SetUp() cnp = new CnpOnline(configManager.getConfig()); } + [OneTimeTearDown] + public void Dispose() + { + Communications.DisposeHttpClient(); + } + [Test] public void Test37() { diff --git a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert5Token.cs b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert5Token.cs index 45587aa6..7d851931 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert5Token.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Certification/TestCert5Token.cs @@ -31,6 +31,12 @@ public void SetUp() cnp = new CnpOnline(configManager.getConfig()); } + [OneTimeTearDown] + public void Dispose() + { + Communications.DisposeHttpClient(); + } + [Test] public void Test50() { diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuth.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuth.cs index 304c59f9..3f4d0c6f 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuth.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuth.cs @@ -649,6 +649,32 @@ public void TestAuthAsync() Assert.AreEqual("000", response.Result.response); } + [Test] + public void TestAuthAsync_newMerchantId() + { + _cnp.SetMerchantId("1234"); + var authorization = new authorization + { + id = "1", + reportGroup = "Planets", + orderId = "12344", + amount = 106, + orderSource = orderSourceType.ecommerce, + card = new cardType + { + type = methodOfPaymentTypeEnum.VI, + number = "414100000000000000", + expDate = "1210" + }, + customBilling = new customBilling { phone = "1112223333" } + }; + + CancellationToken cancellationToken = new CancellationToken(false); + var response = _cnp.AuthorizeAsync(authorization, cancellationToken); + + Assert.AreEqual("000", response.Result.response); + } + [Test] public void SimpleAuthWithSkipRealtimeAUTrue() { @@ -703,7 +729,7 @@ public void SimpleAuthWithSkipRealtimeAUTrueAsync() Assert.AreEqual("000", response.response); Assert.AreEqual(checkDate, response.postDate); } - + [Test] public void SimpleAuthWithSkipRealtimeAUFalse() { @@ -758,7 +784,7 @@ public void SimpleAuthWithSkipRealtimeAUFalseAsync() Assert.AreEqual("000", response.response); Assert.AreEqual(checkDate, response.postDate); } - + [Test] public void SimpleAuthWithLocation() { diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuthReversal.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuthReversal.cs index a25813c0..48e0d536 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuthReversal.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestAuthReversal.cs @@ -81,5 +81,23 @@ public void SimpleAuthReversalWithLocation() Assert.AreEqual("sandbox", response.location); Assert.AreEqual("Approved", response.message); } + + [Test] + public void TestAuthReversalAsync_newMerchantId() + { + _cnp.SetMerchantId("1234"); + var reversal = new authReversal + { + id = "1", + reportGroup = "Planets", + cnpTxnId = 12345678000L, + amount = 106, + payPalNotes = "<'&\">" + }; + + CancellationToken cancellationToken = new CancellationToken(false); + var response = _cnp.AuthReversalAsync(reversal, cancellationToken); + Assert.AreEqual("000", response.Result.response); + } } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBalanceInquiry.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBalanceInquiry.cs index 7c7ee964..5ca6cc97 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBalanceInquiry.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBalanceInquiry.cs @@ -61,5 +61,29 @@ public void TestBalanceInquiryAsync() Assert.AreEqual("000", response.Result.response); } -} + [Test] + public void TestBalanceInquiryAsync_newMerchantId() + { + _cnp.SetMerchantId("1234"); + var balanceInquiry = new balanceInquiry + { + id = "1", + reportGroup = "Planets", + orderId = "12344", + orderSource = orderSourceType.ecommerce, + card = new giftCardCardType + { + type = methodOfPaymentTypeEnum.GC, + number = "414100000000000000", + cardValidationNum = "123", + expDate = "1215", + } + }; + + CancellationToken cancellationToken = new CancellationToken(false); + var response = _cnp.BalanceInquiryAsync(balanceInquiry, cancellationToken); + Assert.AreEqual("000", response.Result.response); + } + + } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCredit.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCredit.cs index b97b818f..e953c765 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCredit.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCredit.cs @@ -214,5 +214,29 @@ public void SimpleCreditWithCardWithLocation() Assert.AreEqual("Approved", response.message); } + [Test] + public void TestCreditWithCardAsync_newMerchantId() + { + _cnp.SetMerchantId("1234"); + var creditObj = new credit + { + id = "1", + reportGroup = "planets", + amount = 106, + orderId = "2111", + orderSource = orderSourceType.ecommerce, + card = new cardType + { + type = methodOfPaymentTypeEnum.VI, + number = "4100000000000001", + expDate = "1210" + } + }; + + CancellationToken cancellationToken = new CancellationToken(false); + var response = _cnp.CreditAsync(creditObj, cancellationToken); + Assert.AreEqual("000", response.Result.response); + } + } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestTimeout.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestTimeout.cs deleted file mode 100644 index 533e5a9d..00000000 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestTimeout.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections.Generic; -using System.Net; -using NUnit.Framework; - -namespace Cnp.Sdk.Test.Functional { - [TestFixture] - internal class TestTimeout - { - private CnpOnline _cnp; - private Dictionary _config; - - [Test] - public void TestTimeoutNotDefined() - { - _config = new ConfigManager().getConfig(); - _config.Remove("timeout"); - - _cnp = new CnpOnline(_config); - - var registerTokenRequest = new registerTokenRequestType - { - id = "1", - reportGroup = "Planets", - orderId = "12344", - accountNumber = "1233456789103801", - }; - - var rtokenResponse = _cnp.RegisterToken(registerTokenRequest); - StringAssert.AreEqualIgnoringCase("Account number was successfully registered", rtokenResponse.message); - } - - [Test] - public void TestTimeoutNotParsable() - { - _config = new ConfigManager().getConfig(); - _config["timeout"] = "notparsableasint"; - - _cnp = new CnpOnline(_config); - - var registerTokenRequest = new registerTokenRequestType - { - id = "1", - reportGroup = "Planets", - orderId = "12344", - accountNumber = "1233456789103801", - }; - - var rtokenResponse = _cnp.RegisterToken(registerTokenRequest); - StringAssert.AreEqualIgnoringCase("Account number was successfully registered", rtokenResponse.message); - } - - [Test] - public void TestTimeoutReached() { - _config = new ConfigManager().getConfig(); - _config["timeout"] = "1"; - - _cnp = new CnpOnline(_config); - - var registerTokenRequest = new registerTokenRequestType { - id = "1", - reportGroup = "Planets", - orderId = "12344", - accountNumber = "1233456789103801", - }; - - Assert.Throws(() => { _cnp.RegisterToken(registerTokenRequest); }); - } - } -} \ No newline at end of file diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAdvancedFraudCheck.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAdvancedFraudCheck.cs index b02f3d57..1f1d26cc 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAdvancedFraudCheck.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAdvancedFraudCheck.cs @@ -28,7 +28,7 @@ public void TestNoCustomAttributes() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123\r\n.*", RegexOptions.Singleline))) .Returns("742802348034313000000Approvedpass42triggered_rule_default"); Communications mockedCommunication = mock.Object; @@ -50,7 +50,7 @@ public void TestCustomAttribute1() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\n.*", RegexOptions.Singleline))) .Returns("742802348034313000000Approvedpass42triggered_rule_default"); Communications mockedCommunication = mock.Object; @@ -73,7 +73,7 @@ public void TestCustomAttribute2() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\n.*", RegexOptions.Singleline))) .Returns("742802348034313000000Approvedpass42triggered_rule_default"); Communications mockedCommunication = mock.Object; @@ -97,7 +97,7 @@ public void TestCustomAttribute3() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\nghi\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\nghi\r\n.*", RegexOptions.Singleline))) .Returns("742802348034313000000Approvedpass42triggered_rule_default"); Communications mockedCommunication = mock.Object; @@ -122,7 +122,7 @@ public void TestCustomAttribute4() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\nghi\r\njkl\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\nghi\r\njkl\r\n.*", RegexOptions.Singleline))) .Returns("742802348034313000000Approvedpass42triggered_rule_default"); Communications mockedCommunication = mock.Object; @@ -148,7 +148,7 @@ public void TestCustomAttribute5() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\nghi\r\njkl\r\nmno\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex("..*123\r\nabc\r\ndef\r\nghi\r\njkl\r\nmno\r\n.*", RegexOptions.Singleline))) .Returns("742802348034313000000Approvedpass42triggered_rule_default"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthReversal.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthReversal.cs index 32e3c53e..d87daa03 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthReversal.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthReversal.cs @@ -31,7 +31,7 @@ public void TestSurchargeAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\nnote.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\nnote.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -50,7 +50,7 @@ public void TestSurchargeAmount_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -70,7 +70,7 @@ public void TestAuthReversalWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\nnote.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\nnote.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthorization.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthorization.cs index 91ef5ce2..42e3cb70 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthorization.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestAuthorization.cs @@ -30,7 +30,7 @@ public void TestFraudFilterOverride() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -56,7 +56,7 @@ public void TestContactShouldSendEmailForEmail_NotZip() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*12345.*gdake@cnp.com.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*12345.*gdake@cnp.com.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -82,7 +82,7 @@ public void Test3dsAttemptedShouldNotSayItem() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2.*3dsAttempted.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2.*3dsAttempted.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -108,7 +108,7 @@ public void Test3dsAuthenticatedShouldNotSayItem() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2.*3dsAuthenticated.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2.*3dsAuthenticated.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -131,7 +131,7 @@ public void TestSecondaryAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -154,7 +154,7 @@ public void TestSurchargeAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline))) .Returns("123"); var mockedCommunication = mock.Object; @@ -176,7 +176,7 @@ public void TestSurchargeAmount_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline))) .Returns("123"); var mockedCommunication = mock.Object; @@ -203,7 +203,7 @@ public void TestMethodOfPaymentAllowsGiftCard() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nGC\r\n414100000000000000\r\n1210\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nGC\r\n414100000000000000\r\n1210\r\n.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -240,7 +240,7 @@ public void TestMethodOfPaymentApplepayAndWallet() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?applepay.*?.*?user.*?.*?.*?123.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?applepay.*?.*?user.*?.*?.*?123.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -270,7 +270,7 @@ public void TestRecurringRequest() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n\r\n\r\nabc123\r\n12\r\n\r\n\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n\r\n\r\nabc123\r\n12\r\n\r\n\r\n.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -297,7 +297,7 @@ public void TestDebtRepayment() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\ntrue\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\ntrue\r\n.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -371,7 +371,7 @@ public void TestSimpleAuthWithFraudCheck() Assert.AreEqual(Regex.Replace(expectedResult, @"\s+", string.Empty), Regex.Replace(auth.Serialize(), @"\s+", string.Empty)); var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*192.168.1.1.*PAP.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*192.168.1.1.*.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -418,7 +418,7 @@ public void TestSimpleAuthWithBillMeLaterRequest() Assert.AreEqual(Regex.Replace(expectedResult, @"\s+", string.Empty), Regex.Replace(auth.Serialize(), @"\s+", string.Empty)); var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*\r\nPresence\r\nData\r\n.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*\r\nPresence\r\nData\r\n.*.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -463,7 +463,7 @@ public void TestAuthWithAdvancedFraud() Assert.AreEqual(Regex.Replace(expectedResult, @"\s+", string.Empty), Regex.Replace(auth.Serialize(), @"\s+", string.Empty)); var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsAny(), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsAny() )) .Returns("123\"ReviewStatus\"800"); var mockedCommunication = mock.Object; @@ -527,7 +527,7 @@ public void TestAuthWithPosCatLevelEnum() Assert.AreEqual(Regex.Replace(expectedResult, @"\s+", string.Empty), Regex.Replace(auth.Serialize(), @"\s+", string.Empty)); var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsAny(), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsAny() )) .Returns("123"); var mockedCommunication = mock.Object; @@ -581,7 +581,7 @@ public void TestOriginalTransaction() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456789.*?12.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456789.*?12.*?", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -605,7 +605,7 @@ public void TestOriginalTransactionWithPin() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nMC\r\n414100000000000000\r\n1210\r\n1234\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nMC\r\n414100000000000000\r\n1210\r\n1234\r\n.*", RegexOptions.Singleline) )) .Returns("123"); var mockedCommunication = mock.Object; @@ -626,7 +626,7 @@ public void TestAuthWithMCC() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline))) .Returns("123"); var mockedCommunication = mock.Object; @@ -649,7 +649,7 @@ public void TestAuthorizationWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline))) .Returns("123sandbox"); var mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestBatch.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestBatch.cs index aec92812..ad34c401 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestBatch.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestBatch.cs @@ -144,8 +144,8 @@ public void TestAccountUpdate() Assert.AreEqual("000", actualAccountUpdateResponse2.response); Assert.IsNull(nullAccountUpdateResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } @@ -205,8 +205,8 @@ public void TestAuth() Assert.AreEqual(124, actualCnpBatchResponse.nextAuthorizationResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextAuthorizationResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -262,8 +262,8 @@ public void TestAuthReversal() Assert.AreEqual(124, actualAuthReversalResponse2.cnpTxnId); Assert.IsNull(nullAuthReversalResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -317,8 +317,8 @@ public void TestCapture() Assert.AreEqual(124, actualCaptureResponse2.cnpTxnId); Assert.IsNull(nullCaptureResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -383,8 +383,8 @@ public void TestCaptureGivenAuth() Assert.AreEqual(124, actualCaptureGivenAuthReponse2.cnpTxnId); Assert.IsNull(nullCaptureGivenAuthReponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -444,8 +444,8 @@ public void TestCredit() Assert.AreEqual(124, actualCreditReponse2.cnpTxnId); Assert.IsNull(nullCreditReponse1); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -499,8 +499,8 @@ public void TestEcheckCredit() Assert.AreEqual(124, actualEcheckCreditResponse2.cnpTxnId); Assert.IsNull(nullEcheckCreditResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -553,8 +553,8 @@ public void TestEcheckRedeposit() Assert.AreEqual(124, actualEcheckRedepositResponse2.cnpTxnId); Assert.IsNull(nullEcheckRedepositResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -621,8 +621,8 @@ public void TestEcheckSale() Assert.AreEqual(124, actualEcheckSalesResponse2.cnpTxnId); Assert.IsNull(nullEcheckSalesResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -689,8 +689,8 @@ public void TestEcheckVerification() Assert.AreEqual(124, actualEcheckVerificationResponse2.cnpTxnId); Assert.IsNull(nullEcheckVerificationResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -750,8 +750,8 @@ public void TestForceCapture() Assert.AreEqual(124, actualForceCaptureResponse2.cnpTxnId); Assert.IsNull(nullForceCaptureResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -811,8 +811,8 @@ public void TestSale() Assert.AreEqual(124, actualSaleResponse2.cnpTxnId); Assert.IsNull(nullSaleResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -866,8 +866,8 @@ public void TestToken() Assert.AreEqual(124, actualRegisterTokenResponse2.cnpTxnId); Assert.IsNull(nullRegisterTokenResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -921,8 +921,8 @@ public void TestUpdateCardValidationNumOnToken() Assert.AreEqual(124, actualUpdateCardValidationNumOnTokenResponse2.cnpTxnId); Assert.IsNull(nullUpdateCardValidationNumOnTokenResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1094,8 +1094,8 @@ public void TestDefaultReportGroup() Assert.IsNull(nullAuthorizationResponse); mockCnpFile.Verify(cnpFile => cnpFile.AppendLineToFile(mockFilePath, It.IsRegex(".*reportGroup=\"Default Report Group\".*", RegexOptions.Singleline))); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1176,8 +1176,8 @@ public void TestRFRRequest() Assert.IsNull(nullCnpBatchResponse); Assert.IsNull(nullRFRResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1227,8 +1227,8 @@ public void TestCancelSubscription() Assert.AreEqual("54321", actualCnpBatchResponse.nextCancelSubscriptionResponse().subscriptionId); Assert.IsNull(actualCnpBatchResponse.nextCancelSubscriptionResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1291,8 +1291,8 @@ public void TestUpdateSubscription() Assert.AreEqual("54321", actualCnpBatchResponse.nextUpdateSubscriptionResponse().subscriptionId); Assert.IsNull(actualCnpBatchResponse.nextUpdateSubscriptionResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1346,8 +1346,8 @@ public void testCreatePlan() Assert.AreEqual("124", actualCnpBatchResponse.nextCreatePlanResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextCreatePlanResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1399,8 +1399,8 @@ public void TestUpdatePlan() Assert.AreEqual("124", actualCnpBatchResponse.nextUpdatePlanResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextUpdatePlanResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1453,8 +1453,8 @@ public void TestActivate() Assert.AreEqual(124, actualCnpBatchResponse.nextActivateResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextActivateResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1507,8 +1507,8 @@ public void testDeactivate() Assert.AreEqual(124, actualCnpBatchResponse.nextDeactivateResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextDeactivateResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1561,8 +1561,8 @@ public void testLoad() Assert.AreEqual(124, actualCnpBatchResponse.nextLoadResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextLoadResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1615,8 +1615,8 @@ public void testUnload() Assert.AreEqual(124, actualCnpBatchResponse.nextUnloadResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextUnloadResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1669,8 +1669,8 @@ public void TestBalanceInquiry() Assert.AreEqual(124, actualCnpBatchResponse.nextBalanceInquiryResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextBalanceInquiryResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1736,8 +1736,8 @@ public void TestEcheckPreNoteSale() Assert.AreEqual(124, actualEcheckPreNoteSaleResponse2.cnpTxnId); Assert.IsNull(nullEcheckPreNoteSalesResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1803,8 +1803,8 @@ public void TestEcheckPreNoteCredit() Assert.AreEqual(124, actualEcheckPreNoteCreditResponse2.cnpTxnId); Assert.IsNull(nullEcheckPreNoteCreditsResponse); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1891,8 +1891,8 @@ public void TestGiftCardAuthReversal() Assert.AreEqual(522547723741503001, actualCnpBatchResponse.nextGiftCardAuthReversalResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextGiftCardAuthReversalResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -1978,8 +1978,8 @@ public void TestGiftCardCapture() Assert.AreEqual(522547723741503001, actualCnpBatchResponse.nextGiftCardCaptureResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextGiftCardCaptureResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -2063,8 +2063,8 @@ public void TestGiftCardCreditWithTxnId() Assert.AreEqual(522547723741503001, actualCnpBatchResponse.nextGiftCardCreditResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextGiftCardCreditResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] @@ -2151,8 +2151,8 @@ public void TestGiftCardCreditWithOrderId() Assert.AreEqual(522547723741503001, actualCnpBatchResponse.nextGiftCardCreditResponse().cnpTxnId); Assert.IsNull(actualCnpBatchResponse.nextGiftCardCreditResponse()); - mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName, It.IsAny>())); - mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny(), It.IsAny>(), mockFileName)); + mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny(), mockFileName )); + mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny() , mockFileName)); } [Test] diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCancelSubscription.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCancelSubscription.cs index 10d59e33..8612e219 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCancelSubscription.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCancelSubscription.cs @@ -26,7 +26,7 @@ public void TestSimple() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\n\r\n.*?.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\n\r\n.*?.*", RegexOptions.Singleline) )) .Returns("12345"); Communications mockedCommunication = mock.Object; @@ -42,7 +42,7 @@ public void TestCancelSubscriptionWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\n\r\n.*?.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\n\r\n.*?.*", RegexOptions.Singleline))) .Returns("12345"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs index 7bc75944..9783bcaa 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs @@ -31,7 +31,7 @@ public void TestSimpleCapture() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote\r\n1234.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote\r\n1234.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -51,7 +51,7 @@ public void TestSurchargeAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\nnote.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\nnote.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -70,7 +70,7 @@ public void TestSurchargeAmount_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -90,7 +90,7 @@ public void TestCaptureWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote\r\n1234.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\nnote\r\n1234.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs index 14d35bd3..ee15343f 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs @@ -30,7 +30,7 @@ public void TestSecondaryAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -49,7 +49,7 @@ public void TestSurchargeAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -67,7 +67,7 @@ public void TestSurchargeAmount_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -84,7 +84,7 @@ public void TestDebtRepayment_True() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\ntrue\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\ntrue\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -101,7 +101,7 @@ public void TestDebtRepayment_False() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nfalse\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nfalse\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -117,7 +117,7 @@ public void TestDebtRepayment_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -137,7 +137,7 @@ public void TestProcessingType() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\ninitialRecurring\r\nabc123\r\n1234.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\ninitialRecurring\r\nabc123\r\n1234.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -158,7 +158,7 @@ public void TestUndefinedProcessingType() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\nabc123\r\n1234.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\nabc123\r\n1234.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -177,7 +177,7 @@ public void TestCaptureAuthWithMCC() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline))) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -196,7 +196,7 @@ public void TestCaptureGivenAuthWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCnpOnline.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCnpOnline.cs index 92ac0c79..8adad697 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCnpOnline.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCnpOnline.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using NUnit.Framework; using Moq; using System.Text.RegularExpressions; @@ -13,12 +12,18 @@ class TestCnpOnline private CnpOnline cnp; - [OneTimeSetUp] + [SetUp] public void SetUpCnp() { cnp = new CnpOnline(); } + [TearDown] + public void Dispose() + { + Communications.DisposeHttpClient(); + } + [Test] public void TestAuth() { @@ -35,7 +40,7 @@ public void TestAuth() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*4100000000000002.*.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*4100000000000002.*.*.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -55,7 +60,7 @@ public void TestAuthReversal() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?12345678000.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?12345678000.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -75,7 +80,7 @@ public void TestCapture() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456000.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456000.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -104,7 +109,7 @@ public void TestCaptureGivenAuth() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000001.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000001.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -128,7 +133,7 @@ public void TestCredit() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000001.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000001.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -146,7 +151,7 @@ public void TestEcheckCredit() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456789101112.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456789101112.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -163,7 +168,7 @@ public void TestEcheckRedeposit() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?123456.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -195,7 +200,7 @@ public void TestEcheckSale() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?12345657890.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?12345657890.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -227,7 +232,7 @@ public void TestEcheckVerification() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?12345657890.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?12345657890.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -251,7 +256,7 @@ public void TestForceCapture() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000001.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000001.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -275,7 +280,7 @@ public void TestSale() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -287,7 +292,7 @@ public void TestSale() [Test] public void TestSale_BadConnection() { - sale sale = new sale + var sale = new sale { id = "21321415412", orderId = "1556632727643", @@ -299,35 +304,14 @@ public void TestSale_BadConnection() } }; - ConfigManager configManager = new ConfigManager(); - //Dictionary config = new Dictionary(); - Dictionary config = configManager.getConfig(); - //config["url"] = Properties.Settings.Default.url; - //config["reportGroup"] = Properties.Settings.Default.reportGroup; - //config["username"] = Properties.Settings.Default.username; - //config["printxml"] = Properties.Settings.Default.printxml; - //config["timeout"] = Properties.Settings.Default.timeout; - config["proxyHost"] = "somegarbage"; - //config["merchantId"] = Properties.Settings.Default.merchantId; - //config["password"] = Properties.Settings.Default.password; + Communications.DisposeHttpClient(); + var config = new ConfigManager().getConfig(); + config["proxyHost"] = "some-garbage"; config["proxyPort"] = "123"; - //config["logFile"] = Properties.Settings.Default.logFile; - //config["neuterAccountNums"] = Properties.Settings.Default.neuterAccountNums; - - CnpOnline tempCnp = new CnpOnline(config); - - Communications comms = new Communications(); - tempCnp.SetCommunication(comms); - bool exceptionRasied = false; - try - { - saleResponse saleresponse = tempCnp.Sale(sale); - } - catch (WebException e) { - exceptionRasied = true; - } + var tempCnp = new CnpOnline(config); - Assert.IsTrue(exceptionRasied,"Web exception not raised."); + // Expect a WebException because an invalid proxy configuration is set + Assert.Throws(() => tempCnp.Sale(sale)); } [Test] @@ -340,7 +324,7 @@ public void TestToken() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?1233456789103801.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?1233456789103801.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -360,7 +344,7 @@ public void TestActivate() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline) )) .Returns(@" @@ -398,7 +382,7 @@ public void TestDeactivate() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -417,7 +401,7 @@ public void TestLoad() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -436,7 +420,7 @@ public void TestUnload() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -455,7 +439,7 @@ public void TestBalanceInquiry() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?2.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -472,7 +456,7 @@ public void TestCreatePlan() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?theCode.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?theCode.*?.*?", RegexOptions.Singleline) )) .Returns("theCode"); Communications mockedCommunication = mock.Object; @@ -489,7 +473,7 @@ public void TestUpdatePlan() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?theCode.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?theCode.*?.*?", RegexOptions.Singleline) )) .Returns("theCode"); Communications mockedCommunication = mock.Object; @@ -514,7 +498,7 @@ public void TestCnpOnlineException() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -545,7 +529,7 @@ public void TestInvalidOperationException() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline) )) .Returns("no xml"); Communications mockedCommunication = mock.Object; @@ -575,7 +559,7 @@ public void TestDefaultReportGroup() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?.*?4100000000000002.*?.*?.*?", RegexOptions.Singleline) )) .Returns(""); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCommunications.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCommunications.cs index 7ee0bb44..ac5e9bc9 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCommunications.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCommunications.cs @@ -1,61 +1,51 @@ using System.Collections.Generic; using NUnit.Framework; - - namespace Cnp.Sdk.Test.Unit { [TestFixture] internal class TestCommunications { - private Communications _objectUnderTest; + private Dictionary config; + private Communications objectUnderTest; [OneTimeSetUp] public void SetUpCnp() { - _objectUnderTest = new Communications(); + config = new Dictionary {["url"] = "https://example.com"}; + objectUnderTest = new Communications(config); } [Test] public void TestSettingProxyPropertiesToNullShouldTurnOffProxy() { - var config = new Dictionary { { "proxyHost", null }, { "proxyPort", null } }; - - Assert.IsFalse(_objectUnderTest.IsProxyOn(config)); + config["proxyHost"] = null; + config["proxyPort"] = null; + Assert.IsFalse(objectUnderTest.IsProxyOn()); } [Test] public void TestSettingProxyPropertiesToEmptyShouldTurnOffProxy() { - var config = new Dictionary { { "proxyHost", "" }, { "proxyPort", "" } }; - - Assert.IsFalse(_objectUnderTest.IsProxyOn(config)); + config["proxyHost"] = ""; + config["proxyPort"] = ""; + Assert.IsFalse(objectUnderTest.IsProxyOn()); } [Test] public void TestSettingLogFileToEmptyShouldTurnOffLogFile() { - var config = new Dictionary { { "logFile", "" } }; - - Assert.IsFalse(_objectUnderTest.IsValidConfigValueSet(config, "logFile")); - - config = null; - - Assert.IsFalse(_objectUnderTest.IsValidConfigValueSet(config, "logFile")); + config["logFile"] = ""; + Assert.IsFalse(objectUnderTest.IsValidConfigValueSet("logFile")); } [Test] public void TestConfigNotPresentInDictionary() { - var config = new Dictionary { }; - - Assert.IsFalse(_objectUnderTest.IsValidConfigValueSet(config, "logFile")); - + Assert.IsFalse(objectUnderTest.IsValidConfigValueSet("logFile")); } - - } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCredit.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCredit.cs index 12e09c97..0f56c126 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCredit.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCredit.cs @@ -31,7 +31,7 @@ public void TestActionReasonOnOrphanedRefund() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*SUSPECT_FRAUD.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*SUSPECT_FRAUD.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -52,7 +52,7 @@ public void TestOrderSource_Set() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2.*ecommerce.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2.*ecommerce.*.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -72,7 +72,7 @@ public void TestSecondaryAmount_Orphan() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -92,7 +92,7 @@ public void TestSecondaryAmount_Tied() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\n>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\n123"); Communications mockedCommunication = mock.Object; @@ -112,7 +112,7 @@ public void TestSurchargeAmount_Tied() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\n>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\n123"); Communications mockedCommunication = mock.Object; @@ -131,7 +131,7 @@ public void TestSurchargeAmount_TiedOptional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n123"); Communications mockedCommunication = mock.Object; @@ -151,7 +151,7 @@ public void TestSurchargeAmount_Orphan() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -170,7 +170,7 @@ public void TestSurchargeAmount_OrphanOptional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -191,7 +191,7 @@ public void TestPos_Tied() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n\r\nabc123\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n\r\nabc123\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -210,7 +210,7 @@ public void TestPos_TiedOptional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -234,7 +234,7 @@ public void TestCreditWithPin() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1234.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1234.*.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -254,7 +254,7 @@ public void TestCreditWithMCC() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\necommerce\r\n0111.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*3\r\n2\r\necommerce\r\n0111.*", RegexOptions.Singleline))) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -274,7 +274,7 @@ public void TestCreditWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*SUSPECT_FRAUD.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*SUSPECT_FRAUD.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckRedeposit.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckRedeposit.cs index f8090baf..b05c749c 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckRedeposit.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckRedeposit.cs @@ -32,7 +32,7 @@ public void TestMerchantData() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1.*.*camp.*affil.*mgi.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1.*.*camp.*affil.*mgi.*.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -53,7 +53,7 @@ public void TestEcheckRedepositWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1.*.*camp.*affil.*mgi.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1.*.*camp.*affil.*mgi.*.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVerification.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVerification.cs index 7f1ccb12..e14f0cd5 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVerification.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVerification.cs @@ -34,18 +34,18 @@ public void TestMerchantData() echeckVerification.merchantData.campaign = "camp"; echeckVerification.merchantData.affiliate = "affil"; echeckVerification.merchantData.merchantGroupingId = "mgi"; - + var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1.*2.*camp.*affil.*mgi.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1.*2.*camp.*affil.*mgi.*.*", RegexOptions.Singleline) )) .Returns("123sandbox"); - + Communications mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); var response = cnp.EcheckVerification(echeckVerification); - + Assert.NotNull(response); Assert.AreEqual("sandbox", response.location); - } + } } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVoid.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVoid.cs index afb8ba8c..ee17b28a 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVoid.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestEcheckVoid.cs @@ -10,7 +10,7 @@ namespace Cnp.Sdk.Test.Unit [TestFixture] class TestEcheckVoid { - + private CnpOnline cnp; [OneTimeSetUp] @@ -24,20 +24,20 @@ public void TestFraudFilterOverride() { echeckVoid echeckVoid = new echeckVoid(); echeckVoid.cnpTxnId = 123456789; - + var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456789.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456789.*", RegexOptions.Singleline) )) .Returns("123sandbox"); - + Communications mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); var response = cnp.EcheckVoid(echeckVoid); - + Assert.NotNull(response); Assert.AreEqual("sandbox", response.location); } - + } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs index 025351ec..757273be 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs @@ -30,7 +30,7 @@ public void TestSecondaryAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -49,7 +49,7 @@ public void TestSurchargeAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -68,7 +68,7 @@ public void TestSurchargeAmount_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -85,7 +85,7 @@ public void TestDebtRepayment_True() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\ntrue\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\ntrue\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -102,7 +102,7 @@ public void TestDebtRepayment_False() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nfalse\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nfalse\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -118,7 +118,7 @@ public void TestDebtRepayment_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -138,7 +138,7 @@ public void TestProcessingType() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\ninitialRecurring.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\ninitialRecurring.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -158,7 +158,7 @@ public void TestUndefinedProcessingType() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -177,7 +177,7 @@ public void TestForceCaptureWithMCC() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline))) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -196,7 +196,7 @@ public void TestForceCaptureWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCard.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCard.cs index f4839a33..9e82c72c 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCard.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCard.cs @@ -32,7 +32,7 @@ public void TestGiftCardAuthReversalSimple() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456789\r\nabc123\r\n500\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456789\r\nabc123\r\n500\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -56,7 +56,7 @@ public void TestGiftCardAuthReversalWithCard() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nGC\r\n414100000000000000\r\n1210\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nGC\r\n414100000000000000\r\n1210\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -84,7 +84,7 @@ public void TestGiftCardCaptureSimple() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n106\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n\r\nabc123\r\n43534345\r\n2017-01-01T00:00:00Z.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n106\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n\r\nabc123\r\n43534345\r\n2017-01-01T00:00:00Z.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -108,7 +108,7 @@ public void TestGiftCardCreditTxnId() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n106\r\n\r\nGC\r\n4100000000000000\r\n1210\r.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n106\r\n\r\nGC\r\n4100000000000000\r\n1210\r.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -133,7 +133,7 @@ public void TestGiftCardCreditOrderId() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2111\r\n106\r\necheckppd\r\n\r\nGC\r\n4100000000000000\r\n1210\r.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2111\r\n106\r\necheckppd\r\n\r\nGC\r\n4100000000000000\r\n1210\r.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -158,7 +158,7 @@ public void TestGiftCardCreditWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2111\r\n106\r\necheckppd\r\n\r\nGC\r\n4100000000000000\r\n1210\r.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2111\r\n106\r\necheckppd\r\n\r\nGC\r\n4100000000000000\r\n1210\r.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCardParentReversal.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCardParentReversal.cs index 17c3bbce..b2490231 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCardParentReversal.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestGiftCardParentReversal.cs @@ -39,7 +39,7 @@ public void DepositReversal() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -68,7 +68,7 @@ public void RefundReversal() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline) )) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; @@ -99,7 +99,7 @@ public void ActivateReversal() reversal.originalSequenceNumber = "123456"; var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n123\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n123\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline) )) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; @@ -130,7 +130,7 @@ public void DeactivateReversal() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline) )) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; @@ -162,7 +162,7 @@ public void LoadReversal() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline) )) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; @@ -194,7 +194,7 @@ public void UnloadReversal() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*123456000\r\n\r\nGC\r\n414100000000000000\r\n1210\r\n1234\r\n\r\n123\r\n123\r\n2017-01-01T00:00:00Z\r\n123\r\n123456.*", RegexOptions.Singleline) )) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestQueryTransactionRequest.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestQueryTransactionRequest.cs index dbd0330a..8491d467 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestQueryTransactionRequest.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestQueryTransactionRequest.cs @@ -46,7 +46,7 @@ public void TestQueryTransactionResponse() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*0002015-12-03T10:30:02Original transaction found756027696701750GenericOrderId0002015-04-14T12:04:592015-04-14Approved055858756027696701751GenericOrderId0002015-04-14T12:04:592015-04-14Approved055858000Deposit approvedsandbox"); Communications mockedCommunication = mock.Object; @@ -88,7 +88,7 @@ public void TestQueryTransactionUnavailableResponse() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1522015-12-03T14:45:31Original transaction found but response not yet availablesandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestRegisterTokenRequest.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestRegisterTokenRequest.cs index 66115441..923dc2a2 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestRegisterTokenRequest.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestRegisterTokenRequest.cs @@ -29,7 +29,7 @@ public void TestSimpleRequest() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*4100000000000001.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*4100000000000001.*.*", RegexOptions.Singleline) )) .Returns("4801Token Successfully Registered2012-10-10T10:17:03sandbox"); Communications mockedCommunication = mock.Object; @@ -50,7 +50,7 @@ public void TestCanContainCardValidationNum() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*4100000000000001.*123.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*4100000000000001.*123.*.*", RegexOptions.Singleline) )) .Returns("4801Token Successfully Registered2012-10-10T10:17:03"); Communications mockedCommunication = mock.Object; @@ -77,7 +77,7 @@ public void TestSimpleRequestWithApplepay() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*?user.*?.*?.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*.*?user.*?.*?.*", RegexOptions.Singleline) )) .Returns("4801Token Successfully Registered2012-10-10T10:17:03"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs index e321e0af..8a349c4e 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs @@ -31,7 +31,7 @@ public void TestFraudFilterOverride() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*false.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*false.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -50,7 +50,7 @@ public void TestSurchargeAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -68,7 +68,7 @@ public void TestSurchargeAmount_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -95,7 +95,7 @@ public void TestRecurringRequest() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n\r\n\r\nabc123\r\n12\r\n\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n\r\n\r\nabc123\r\n12\r\n\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -145,7 +145,7 @@ public void TestRecurringRequest_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -171,7 +171,7 @@ public void Test_CnpInternalRecurringRequest() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex("true\r\n\r\n123\r\n456\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex("true\r\n\r\n123\r\n456\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -193,7 +193,7 @@ public void Test_CnpInternalRecurringRequest_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*true\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -210,7 +210,7 @@ public void TestDebtRepayment_True() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\ntrue\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\ntrue\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -227,7 +227,7 @@ public void TestDebtRepayment_False() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nfalse\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nfalse\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -243,7 +243,7 @@ public void TestDebtRepayment_Optional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -262,7 +262,7 @@ public void TestSecondaryAmount() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\n1\r\necommerce.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -293,7 +293,7 @@ public void TestApplepayAndWallet() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?user.*?.*?123.*?.*?.*?", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?.*?user.*?.*?123.*?.*?.*?", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -318,7 +318,7 @@ public void SimpleSaleWithDirectDebit() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nMerchant\r\nFirstRecurring\r\n123456789123456789\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nMerchant\r\nFirstRecurring\r\n123456789123456789\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -341,7 +341,7 @@ public void SimpleSaleWithProcessTypeNetIdTranAmt() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*accountFunding\r\nTest\r\n123.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*accountFunding\r\nTest\r\n123.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -364,7 +364,7 @@ public void SimpleSaleWithIdealResponse() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nUS\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nUS\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -387,7 +387,7 @@ public void SimpleSaleWithGiropayResponse() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nUS\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nUS\r\n.*", RegexOptions.Singleline) )) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -410,7 +410,7 @@ public void SimpleSaleWithSofortResponse() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nUS\r\n.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\nUS\r\n.*", RegexOptions.Singleline))) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -429,7 +429,7 @@ public void TestSaleWithMCC() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*2\r\necommerce\r\n0111.*", RegexOptions.Singleline))) .Returns("123"); Communications mockedCommunication = mock.Object; @@ -449,7 +449,7 @@ public void TestSaleWithLocation() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*false.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*false.*", RegexOptions.Singleline))) .Returns("123sandbox"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateCardValidationNumOnToken.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateCardValidationNumOnToken.cs index 8170f0ea..a13989b5 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateCardValidationNumOnToken.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateCardValidationNumOnToken.cs @@ -31,7 +31,7 @@ public void TestSimpleRequest() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*12344.*1111222233334444.*321.*.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*12344.*1111222233334444.*321.*.*", RegexOptions.Singleline) )) .Returns("412344801Token Successfully Registered2012-10-10T10:17:03sandbox"); Communications mockedCommunication = mock.Object; @@ -54,8 +54,8 @@ public void TestOrderIdIsOptional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1111222233334444.*321.*.*", RegexOptions.Singleline), It.IsAny>())) - //mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*1111222233334444.*321.*.*", RegexOptions.Singleline) )) + //mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*", RegexOptions.Singleline) )) .Returns("4801Token Successfully Registered2012-10-10T10:17:03"); Communications mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateSubscription.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateSubscription.cs index aa8a062a..efd66790 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateSubscription.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestUpdateSubscription.cs @@ -43,7 +43,7 @@ public void TestSimple() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\nabcdefg\r\n\r\nGreg Dake.*?\r\n\r\nVI.*?\r\n2002-10-09\r\n\r\n.*?.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\nabcdefg\r\n\r\nGreg Dake.*?\r\n\r\nVI.*?\r\n2002-10-09\r\n\r\n.*?.*", RegexOptions.Singleline) )) .Returns("456000Approved2013-09-0412345"); var mockedCommunication = mock.Object; @@ -82,7 +82,7 @@ public void TestWithToken() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\nabcdefg\r\n\r\nGreg Dake.*?\r\n.*?0123456789012345678\r\n\r\n2002-10-09\r\n\r\n.*?.*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*\r\n12345\r\nabcdefg\r\n\r\nGreg Dake.*?\r\n.*?0123456789012345678\r\n\r\n2002-10-09\r\n\r\n.*?.*", RegexOptions.Singleline) )) .Returns("456000Approved2013-09-0412345"); var mockedCommunication = mock.Object; diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestVoid.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestVoid.cs index cabd4fe4..6ef7fbfc 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestVoid.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestVoid.cs @@ -27,9 +27,9 @@ public void TestRecyclingDataOnVoidResponse() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*", RegexOptions.Singleline))) .Returns("1230002013-01-31T15:48:092013-01-31Approved456sandbox"); - + Communications mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); voidResponse response = cnp.DoVoid(voidTxn); @@ -46,7 +46,7 @@ public void TestRecyclingDataOnVoidResponseIsOptional() var mock = new Mock(); - mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*", RegexOptions.Singleline), It.IsAny>())) + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*", RegexOptions.Singleline) )) .Returns("1230002013-01-31T15:48:092013-01-31Approved"); Communications mockedCommunication = mock.Object;