public void Test_Initialize_Transaction_Successful_Message() { connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID)); cashout = new Cashout(connectionClient); SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("reference", Util.generateTransactionRefrenceNo()); param.Add("mchShortName", "Jerry's shop"); param.Add("productName", "Apple AirPods Pro"); param.Add("productDesc", "The best wireless earphone in history"); param.Add("userPhone", "+2349876543210"); param.Add("userRequestIp", "123.123.123.123"); param.Add("amount", "100"); param.Add("currency", "NGN"); param.Add("payMethods", new String[] { "account", "qrcode", "bankCard", "bankAccount" }); param.Add("payTypes", new String[] { "BalancePayment", "BonusPayment", "OWealth" }); param.Add("callbackUrl", "https://you.domain.com/callbackUrl"); param.Add("returnUrl", "https://you.domain.com/returnUrl"); param.Add("expireAt", "10"); JObject response = cashout.initializeTransaction(param).Result; transactionCheckStatusInput = (JObject)response.GetValue("data"); Assert.AreEqual("SUCCESSFUL", response.GetValue("message").ToString()); }
public void Run() { if (!TryStartListening()) { return; } while (true) { try { IConnectionClient client = server.Accept(); if (client == null) { break; } ManagedClient managedClient = new ManagedClient(client, nextId++); lock (clientsLocker) { if (state.Value == CSState.Listening || state.Value == CSState.AgentsAccepting) { clients.Add(managedClient); tasks.Add(Task.Run(() => HandleCommunication(managedClient))); } } } catch (SocketException) { CSLogger.LogError("Some error with TCPListener occured.\n"); Kill(); } } CSLogger.Log($"Communication Server stopped listening for clients.\n"); Task.WaitAll(tasks.ToArray()); }
public void Test_Transfer_To_User_Wallet_Successful() { SortedDictionary <String, Object> receiver = new SortedDictionary <String, Object>(); receiver.Add("name", "Adny Lee"); receiver.Add("phoneNumber", "+2348131393827"); receiver.Add("type", "USER"); SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("amount", "100"); param.Add("country", "NG"); param.Add("currency", "NGN"); param.Add("reason", "transfer reason message"); param.Add("receiver", receiver); param.Add("reference", Util.generateTransactionRefrenceNo()); String paramString = Util.mapToJsonString(param); String signature = Util.calculateHMAC(paramString, PRIVATEKEY); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(signature, MERCHANTID)); transaction = new Transfer(connectionClient); JObject response = transaction.transferToWallet(param).Result; walletTransferUserStatusInput = (JObject)response.GetValue("data"); Assert.AreEqual("SUCCESSFUL", response.GetValue("message").ToString()); }
public ActionResult Index() { try { _iConnectionClient = new ClientConnection(); dynamic Response = _iConnectionClient.GetSavedUserDetails(); if (Response == null) { ViewBag.result = new List <UserDetails>(); } else { ViewBag.result = GetUserDetails(Response); } _errorList.Clear(); ViewBag.Error = _errorList; return(View()); } catch (Exception ex) { Logger.Fatal(ex.Message); throw; } finally { _iConnectionClient.CloseConnection(); } }
public void Test_Transfer_To_Bank_Successful() { SortedDictionary <String, Object> receiver = new SortedDictionary <String, Object>(); receiver.Add("bankAccountNumber", "22222222222222"); receiver.Add("bankCode", "058"); receiver.Add("name", "test_20191123132233"); SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("amount", "100"); param.Add("country", "NG"); param.Add("currency", "NGN"); param.Add("reason", "transfer reason message"); param.Add("receiver", receiver); param.Add("reference", Util.generateTransactionRefrenceNo()); String paramString = Util.mapToJsonString(param); String signature = Util.calculateHMAC(paramString, PRIVATEKEY); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(signature, MERCHANTID)); transaction = new Transfer(connectionClient); JObject response = transaction.transferToBank(param).Result; bankTransferStatusInput = (JObject)response.GetValue("data"); String message = response.GetValue("message").ToString(); Assert.AreEqual(message, "SUCCESSFUL"); }
private void ClientLauncher(string serverAddress, int serverPort) { this.serverPort = serverPort; this.serverAddress = IPAddress.Parse(serverAddress); this.connection = new TCPClientAdapter(); this.connection.Connect(this.serverAddress, serverPort); }
public void Test_Get_All_Supporting_Countries() { connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID)); transaction = new Transfer(connectionClient); JObject response = transaction.allSupportingCountries().Result; Assert.AreEqual("SUCCESSFUL", response.GetValue("message").ToString()); }
public void RunBeforeEveryTest() { var networkUtilities = new NetworkUtilities(); _localIpAddress = networkUtilities.GetLocalIPAddress(); _server = new TcpConnectionServer(_localIpAddress, 15845); _testClient = Substitute.For <IConnectionClient>(); }
public ClientModel(IConnectionClient tcpClient, IResponseMessageFactory responseMessageFactory) { _tcpClient = tcpClient; _responseMessageFactory = responseMessageFactory; _messageDictionary = new ConcurrentDictionary <Guid, string>(); Task.Run(async() => await ReadNewResponse()); }
public GameMaster() { this.configuration = new GameMasterConfiguration(); this.connectionClient = new TCPClientAdapter(); this.status = GameMasterStatus.Active; teamBlueGuids = new List <PlayerGuid>(); teamRedGuids = new List <PlayerGuid>(); isGuiWorking = false; debug = true; }
public void Test_Query_Balance_All_Account_Success() { connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID)); inquiry = new Inquiry(connectionClient); JObject response = inquiry.balanceForAllAccount().Result; String message = response.GetValue("message").ToString(); JObject data = (JObject)response.GetValue("data"); Assert.AreEqual(message, "SUCCESSFUL"); }
private void Setup() { _timeProvider = new UnityTimeProvider(); _serverList = new ServerList(_timeProvider); _serverList.ServerAdded += AddServerToDropDown; _serverList.ServerRemoved += RemoveServerFromDropDown; _serverList.RemoveSelectedServer += DisconnectFromSelectedServer; _popupServerNames.Clear(); ConnectionClient = new TcpConnectionClient(); PostSetup(); }
private async Task HandleClient(IConnectionClient tcpClient) { var clientId = tcpClient.GetId(); _notification.Warning("Server", $"Client{clientId} connected!"); var responseSender = new ResponseSender(tcpClient); await HandelNewMessage(tcpClient, responseSender); _notification.Error("Server", $"Client{clientId} dropped out"); }
private async Task <string> GetNewMessage(IConnectionClient tcpClient) { try { return(await(Task.Run(tcpClient.ReadMessageAsync))); } catch (IOException ex) { //When the connected clients console window closing with/without 'Bye' command } return(null); }
public static async Task <string> ReadMessageAsync(this IConnectionClient tcpClient) { if (!tcpClient.Connected) { return(null); } var networkStream = tcpClient.GetStream(); var reader = new StreamReader(networkStream); return(await reader.ReadLineAsync()); }
public ResponseSender(IConnectionClient tcpClient) { _tcpClient = tcpClient; if (!tcpClient.Connected) { throw new ClientIsNotConnectException(); } Connected = true; var networkStream = tcpClient.GetStream(); _streamWriter = new StreamWriter(networkStream, Encoding.ASCII); _streamReader = new StreamReader(networkStream, Encoding.ASCII); }
public void Test_Get_All_Supporting_Banks() { SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("countryCode", "NG"); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID)); transaction = new Transfer(connectionClient); JObject response = transaction.allSupportingBanks(param).Result; Assert.AreEqual("SUCCESSFUL", response.GetValue("message").ToString()); }
public static async Task <bool> WriteMessageAsync(this IConnectionClient tcpClient, string message) { if (!tcpClient.Connected) { return(false); } var networkStream = tcpClient.GetStream(); var writer = new StreamWriter(networkStream); await writer.WriteLineAsync(message); writer.Flush(); return(true); }
public void Test_Validate_Merchant_Successful() { SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("email", "*****@*****.**"); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID)); inquiry = new Inquiry(connectionClient); JObject response = inquiry.validateMerchant(param).Result; String message = response.GetValue("message").ToString(); Assert.AreEqual(message, "SUCCESSFUL"); }
public void Test_Validate_User_Successful() { SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("phoneNumber", "+2349876543210"); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID)); inquiry = new Inquiry(connectionClient); JObject response = inquiry.validateUser(param).Result; String message = response.GetValue("message").ToString(); Assert.AreEqual(message, "SUCCESSFUL"); }
private async Task HandelNewMessage(IConnectionClient tcpClient, ResponseSender responseSender) { string message = await GetNewMessage(tcpClient); if (message == null) { return; } var messageData = MessageFactory.Create(message); _notification.Info($"Client {tcpClient.GetId()} said", messageData.Text); _ = Task.Run(() => ReplyToMessage(responseSender, messageData)); await HandelNewMessage(tcpClient, responseSender); }
public void Test_Verify_AccountAndReturnAllocatedAccountName_Successful() { SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("bankCode", "058"); param.Add("bankAccountNo", "45345343434"); param.Add("countryCode", "NG"); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID)); inquiry = new Inquiry(connectionClient); JObject response = inquiry.verifyAccountAndReturnAllocatedAccountName(param).Result; String message = response.GetValue("message").ToString(); Assert.AreEqual(message, "SUCCESSFUL"); }
public void Test_Bank_Transfer_Status_Successful() { SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("orderNo", bankTransferStatusInput.GetValue("orderNo").ToString()); param.Add("reference", bankTransferStatusInput.GetValue("reference").ToString()); String paramString = Util.mapToJsonString(param); String signature = Util.calculateHMAC(paramString, PRIVATEKEY); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(signature, MERCHANTID)); transaction = new Transfer(connectionClient); JObject response = transaction.checkBankTransferStatus(param).Result; Assert.AreEqual("SUCCESSFUL", response.GetValue("message")); }
public void Test_Transaction_Close_Successful() { // Sorted in Alphabetic Order SortedDictionary <String, Object> param = new SortedDictionary <String, Object>(); param.Add("orderNo", transactionCheckStatusInput.GetValue("orderNo").ToString()); param.Add("reference", transactionCheckStatusInput.GetValue("reference").ToString()); String paramString = Util.mapToJsonString(param); String signature = Util.calculateHMAC(paramString, PRIVATEKEY); connectionClient = new ConnectionClient(BASEURL, Util.getHeader(signature, MERCHANTID)); cashout = new Cashout(connectionClient); JObject response = cashout.closeTransaction(param).Result; String message = response.GetValue("message").ToString(); Assert.AreEqual(message, "SUCCESSFUL"); }
public Cashout(IConnectionClient connectionClient) { this._connectionClient = connectionClient; }
public ManagedClient(IConnectionClient client, int id) { this.client = client; this.Id = id; }
public void Register(IConnectionClient connectionClient) { clients.Add(connectionClient); }
public void UnRegister(IConnectionClient connectionClient) { clients.Remove(connectionClient); }
public Inquiry(IConnectionClient connectionClient) { this._connectionClient = connectionClient; }
public ActionResult Index(IdValidatorModel id) { _iConnectionClient = new ClientConnection(); if (!string.IsNullOrEmpty(id.IdNumber)) { try { dynamic Response = _iConnectionClient.GetServiceResponse(id.IdNumber); string valid = Response.Valid; if (valid == "True") { UserDetails result = GetUserDetails(Response); _userDetails.Add(result); ViewBag.Error = _errorList; ViewBag.result = _userDetails; } else { dynamic UserDetail = _iConnectionClient.GetSavedUserDetails(); if (UserDetail == null) { ViewBag.result = new List <UserDetails>(); } else { if (ViewBag.result.Count == 0) { ViewBag.result = new List <UserDetails>(); } else { foreach (var user in UserDetail.UserDetails) { _userDetails.Add(GetUserDetails(user)); } ViewBag.result = _userDetails; } } foreach (var error in Response.ErrorLists) { _errorList.Add(error.error.ToString()); } ViewBag.Error = _errorList; } } catch (Exception ex) { Logger.Fatal(ex.Message); throw; } finally { _iConnectionClient.CloseConnection(); } } return(View()); }