public static async Task WriteConsole(string message, messageTypeEnum msgType) { var _dt = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); if (msgType == messageTypeEnum.Error) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(_dt + " Error: " + message); Console.ResetColor(); } else if (msgType == messageTypeEnum.Client) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(_dt + " Client: " + message); Console.ResetColor(); } else if (msgType == messageTypeEnum.Server) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(_dt + " Server: " + message); Console.ResetColor(); } else if (msgType == messageTypeEnum.Status) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(_dt + " Status: " + message); Console.ResetColor(); } }
public void MockdeleteCustomerProfileTest() { //define all mocked objects as final var mockController = GetMockController <deleteCustomerProfileRequest, deleteCustomerProfileResponse>(); var mockRequest = new deleteCustomerProfileRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, }; var mockResponse = new deleteCustomerProfileResponse { refId = "1234", sessionToken = "sessiontoken", }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <deleteCustomerProfileRequest, deleteCustomerProfileResponse, deleteCustomerProfileController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); }
public void MockauthenticateTestTest() { //define all mocked objects as final var mockController = GetMockController <authenticateTestRequest, authenticateTestResponse>(); var mockRequest = new authenticateTestRequest { merchantAuthentication = new merchantAuthenticationType() { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, }; var mockResponse = new authenticateTestResponse { refId = "1234", sessionToken = "sessiontoken", }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <authenticateTestRequest, authenticateTestResponse, authenticateTestController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); // Assert.IsNotNull(controllerResponse.); LogHelper.info(Logger, "authenticateTest: Details:{0}", controllerResponse); }
public serverMessage(string fromId, string fromServerName, messageTypeEnum mType, string message) { this.fromServerId = fromId; this.fromServerName = fromServerName; messageJsonBody = message; messageType = mType; createDt = System.DateTime.Now; }
public void MockARBGetSubscriptionListTest() { //define all mocked objects as final var mockController = GetMockController <ARBGetSubscriptionListRequest, ARBGetSubscriptionListResponse>(); var mockRequest = new ARBGetSubscriptionListRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, refId = RefId, searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive, paging = new Paging { limit = 100, offset = 1 }, sorting = new ARBGetSubscriptionListSorting { orderBy = ARBGetSubscriptionListOrderFieldEnum.id, orderDescending = false }, }; var subscriptionDetail = new SubscriptionDetail { id = 1234, accountNumber = "1234", amount = SetValidTransactionAmount(Counter) / 100, }; var subscriptionDetails = new List <SubscriptionDetail> { subscriptionDetail }; var mockResponse = new ARBGetSubscriptionListResponse { refId = "1234", sessionToken = "sessiontoken", subscriptionDetails = subscriptionDetails.ToArray(), totalNumInResultSet = subscriptionDetails.Count, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <ARBGetSubscriptionListRequest, ARBGetSubscriptionListResponse, ARBGetSubscriptionListController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.subscriptionDetails); LogHelper.info(Logger, "ARBGetSubscriptionList: Count:{0}, Details:{1}", controllerResponse.totalNumInResultSet, controllerResponse.subscriptionDetails); }
public void MockcreateFingerPrintTest() { var fingerPrintSupportInformation = new fingerPrintSupportInformationType { amount = SetValidTransactionAmount(Counter) / 100, currencyCode = "INR", sequence = CounterStr, timestamp = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture), }; //define all mocked objects as final var mockController = GetMockController <createFingerPrintRequest, createFingerPrintResponse>(); var mockRequest = new createFingerPrintRequest { merchantAuthentication = new merchantAuthenticationType() { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, supportInformation = fingerPrintSupportInformation, }; var mockResponse = new createFingerPrintResponse { refId = "1234", sessionToken = "sessiontoken", supportInformation = fingerPrintSupportInformation, fingerPrint = new fingerPrintType { sequence = fingerPrintSupportInformation.sequence, timestamp = fingerPrintSupportInformation.timestamp, hashValue = CounterStr, }, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <createFingerPrintRequest, createFingerPrintResponse, createFingerPrintController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.fingerPrint); LogHelper.info(Logger, "createFingerPrint: Details:{0}", controllerResponse.fingerPrint); }
public void MockcreateCustomerProfileTransactionTest() { //define all mocked objects as final var mockController = GetMockController <createCustomerProfileTransactionRequest, createCustomerProfileTransactionResponse>(); var mockRequest = new createCustomerProfileTransactionRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, transaction = new profileTransactionType { Item = new profileTransAuthCaptureType(), }, }; var transactionResponse = new transactionResponse() { accountNumber = "1234", }; var mockResponse = new createCustomerProfileTransactionResponse { refId = "1234", sessionToken = "sessiontoken", transactionResponse = transactionResponse, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <createCustomerProfileTransactionRequest, createCustomerProfileTransactionResponse, createCustomerProfileTransactionController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.transactionResponse); LogHelper.info(Logger, "createCustomerProfileTransaction: Details:{0}", controllerResponse.transactionResponse); }
protected void SetMockControllerExpectations <TQ, TS, TT> ( IApiOperation <TQ, TS> mockController, TQ mockRequest, TS mockResponse, ANetApiResponse errorResponse, List <String> results, messageTypeEnum messageType) where TQ : ANetApiRequest where TS : ANetApiResponse where TT : IApiOperation <TQ, TS> { var mockEnvironment = AuthorizeNet.Environment.CUSTOM; //using (MockContext.Unordered()) { //Expect.On(mockController).Any.Method(i => i.Execute(mockEnvironment)); Expect.On(mockController).Any.Method(i => i.Execute(mockEnvironment)).With(mockEnvironment); Expect.On(mockController).Any.Method(i => i.GetApiResponse()).WillReturn(mockResponse); //Expect.On(mockController).Between(0, 10).Method(i => i.ExecuteWithApiResponse(mockEnvironment)).WillReturn(mockResponse); Expect.On(mockController).Any.Method(i => i.ExecuteWithApiResponse(mockEnvironment)).With(mockEnvironment).WillReturn(mockResponse); Expect.On(mockController).Any.Method(i => i.GetResults()).WillReturn(results); Expect.On(mockController).Any.Method(i => i.GetResultCode()).WillReturn(messageType); Expect.On(mockController).Any.Method(i => i.GetErrorResponse()).WillReturn(errorResponse); } if (null != mockRequest && null != mockResponse) { mockResponse.refId = mockRequest.refId; } var realController = Activator.CreateInstance(typeof(TT), mockRequest); Assert.IsNotNull(realController); LogHelper.info(Logger, "Request: {0}", mockRequest); ShowProperties(mockRequest); LogHelper.info(Logger, "Response: {0}", mockResponse); ShowProperties(mockResponse); }
public void MockmobileDeviceLoginTest() { //define all mocked objects as final var mockController = GetMockController <mobileDeviceLoginRequest, mobileDeviceLoginResponse>(); var mockRequest = new mobileDeviceLoginRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, }; var transRetailInfoType = new transRetailInfoType { deviceType = "android", marketType = "marketplace", }; var mockResponse = new mobileDeviceLoginResponse { refId = "1234", sessionToken = "sessiontoken", merchantAccount = transRetailInfoType, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <mobileDeviceLoginRequest, mobileDeviceLoginResponse, mobileDeviceLoginController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.merchantAccount); LogHelper.info(Logger, "mobileDeviceLogin: Details:{0}", controllerResponse.merchantAccount); }
public void MockcreateCustomerProfileTest() { //define all mocked objects as final var mockController = GetMockController <createCustomerProfileRequest, createCustomerProfileResponse>(); var mockRequest = new createCustomerProfileRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, }; var mockResponse = new createCustomerProfileResponse { refId = "1234", sessionToken = "sessiontoken", customerProfileId = "1234", customerPaymentProfileIdList = new [] { "12345" }, customerShippingAddressIdList = new[] { "12345" }, validationDirectResponseList = new string[] {}, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <createCustomerProfileRequest, createCustomerProfileResponse, createCustomerProfileController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.customerProfileId); LogHelper.info(Logger, "createCustomerProfile: Details:{0}", controllerResponse.customerProfileId); }
public Message(string msg) { /*************************** * Takes a message in string form. * This string could be from the console, * the network or a script file. ***************************/ string[] splitMessage = msg.Split(','); //Split up parameters. try { //SomeEnum enum = (SomeEnum)Enum.Parse(typeof(SomeEnum), "EnumValue"); targetHost = (Convert.ToInt32(splitMessage[0])); messageType= (messageTypeEnum)Enum.Parse(typeof(messageTypeEnum), splitMessage[1]); message = (messageEnum)Enum.Parse(typeof(messageEnum), splitMessage[2]); arguments = splitMessage[3]; if(splitMessage.Length > 5) //Long form { try { requestingHost = Convert.ToInt32( splitMessage[4]); key = Convert.ToInt32( splitMessage[5]); } catch(Exception ex) { Debug.Write("MESSAGE INIT EX : \n" + msg); } } //dbgLog("Create message from string : " + m.ToString()); } catch (Exception ex) { Debug.WriteLine("Exception parsing message ex : " + ex.ToString()); // throw new ArgumentException("Invalid message string exception", msg); //dbgLog("Message from string exception ex : " + ex.ToString()); try { /*debugLog("Received string message : " + msg.ToString()); debugLog("S0 = " + splitMessage[0]); debugLog("S1 = " + splitMessage[1]); debugLog("S2 = " + splitMessage[2]); debugLog("S3 = " + splitMessage[3]);*/ } catch (Exception ex2) { //dbgLog("Could not print values."); } //dbgLog("\n\n"); //printEnumValues(); } }
private void handleHIDEvent(messageTypeEnum msgType, messageEnum msg, string arguments) { //MessageBox.Show(arguments); Debug.WriteLine("handelHIDEvent message:" + msg.ToString() + " : " + arguments); generateMessage(new Message(owner.targetHost, msgType, msg, arguments)); }
public void MockgetCustomerPaymentProfileListTest() { //define all mocked objects as final var mockController = GetMockController <getCustomerPaymentProfileListRequest, getCustomerPaymentProfileListResponse>(); var mockRequest = new getCustomerPaymentProfileListRequest { merchantAuthentication = new merchantAuthenticationType() { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, searchType = CustomerPaymentProfileSearchTypeEnum.cardsExpiringInMonth, month = "2020-12" }; var BankAccountMaskedType = new bankAccountMaskedType() { accountType = bankAccountTypeEnum.savings, accountTypeSpecified = true, routingNumber = "1234", accountNumber = "1234", nameOnAccount = "Test", echeckType = echeckTypeEnum.ARC }; var PaymentMaskedType = new paymentMaskedType() { Item = BankAccountMaskedType }; var CustomerAddress = new customerAddressType { firstName = GetRandomString("FName"), lastName = GetRandomString("LName"), company = GetRandomString("Company"), address = GetRandomString("StreetAdd"), city = "Bellevue", state = "WA", zip = "98000", country = "USA", phoneNumber = FormatToPhone(Counter), faxNumber = FormatToPhone(Counter + 1), }; var paymentProfile = new customerPaymentProfileListItemType() { customerPaymentProfileId = 1234, customerProfileId = 1234, billTo = CustomerAddress, payment = PaymentMaskedType }; var PaymentProfiles = new List <customerPaymentProfileListItemType> { paymentProfile }; var mockResponse = new getCustomerPaymentProfileListResponse { refId = "1234", sessionToken = "sessiontoken", totalNumInResultSet = PaymentProfiles.Count, paymentProfiles = PaymentProfiles.ToArray() }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <getCustomerPaymentProfileListRequest, getCustomerPaymentProfileListResponse, getCustomerPaymentProfileListController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.totalNumInResultSet); Assert.IsNotNull(controllerResponse.paymentProfiles); LogHelper.info(Logger, "getCustomerPaymentProfileList: Details:{0}", controllerResponse.paymentProfiles); }
private void handleHIDEvent(messageTypeEnum msgType, messageEnum msg, string arguments) { //Debug.WriteLine("handelHIDEvent message:" +message); generateMessage(new Message(msgType, msg, arguments)); }
public Message(messageTypeEnum mt, messageEnum msg, String args) { messageType = new messageTypeEnum(); messageType = mt; message = msg; arguments = args; }
public serverMessage(baseServer server, messageTypeEnum mType, string message) : this(server.id, server._serverName, mType, message) { }
public void MockARBGetSubscriptionTest() { //define all mocked objects as final var mockController = GetMockController <ARBGetSubscriptionRequest, ARBGetSubscriptionResponse>(); var mockRequest = new ARBGetSubscriptionRequest { merchantAuthentication = new merchantAuthenticationType() { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, subscriptionId = "1234" }; var customerPaymentProfileMaskedType = new customerPaymentProfileMaskedType { customerPaymentProfileId = "1234", }; Random rnd = new Random(DateTime.Now.Millisecond); var SubscriptionMaskedType = new ARBSubscriptionMaskedType() { name = "Test", paymentSchedule = new paymentScheduleType { interval = new paymentScheduleTypeInterval { length = 1, unit = ARBSubscriptionUnitEnum.months, }, startDate = DateTime.UtcNow, totalOccurrences = 12 }, amount = 9.99M, amountSpecified = true, trialAmount = 100, trialAmountSpecified = true, status = ARBSubscriptionStatusEnum.active, statusSpecified = true, profile = new subscriptionCustomerProfileType() { paymentProfile = customerPaymentProfileMaskedType, }, order = new orderType { description = string.Format("member monthly {0}", rnd.Next(99999)) } }; var mockResponse = new ARBGetSubscriptionResponse { refId = "1234", sessionToken = "sessiontoken", subscription = SubscriptionMaskedType }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <ARBGetSubscriptionRequest, ARBGetSubscriptionResponse, ARBGetSubscriptionController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.subscription); LogHelper.info(Logger, "ARBGetSubscription: Details:{0}", controllerResponse.subscription); }
public int targetHost = -2; //-2: Unset/nowhere, -1: To log, 0 Internal, n host number. #endregion Fields #region Constructors public Message(int targetHost, messageTypeEnum mt, messageEnum msg, String args) { this.targetHost = targetHost; // messageType = new messageTypeEnum(); messageType = mt; message = msg; arguments = args; }