public void Ping_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); facade.Display.ShowMessage("yay!", null, DisplayPaddingType.Center); facade.Communication.ClosePinpadConnection("adios"); bool status = facade.Communication.Ping(); }
//[Test] public void Pinpad_SetTimeoutWriteAndRead() { IPinpadConnection conn = PinpadConnectionProvider.GetAt("COM4"); PinpadCommunication comm = new PinpadCommunication(conn); comm.SetTimeout(5000, 5000); Assert.AreEqual(conn.ReadTimeout, 5000); Assert.AreEqual(conn.WriteTimeout, 5000); }
public void Pinpad_GetValueInOptionsStringWithCircularBehavior_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadCommunication comm = new PinpadCommunication(conn); PinpadInfos infos = new PinpadInfos(comm); IPinpadDisplay display = new PinpadDisplay(comm); PinpadKeyboard key = new PinpadKeyboard(comm, infos, display); string result = key.DataPicker.GetValueInOptions("Carnaval", true, "Simpatiaequaseamor", "OrquestraVoadora", "SargentoPimenta", "Carmelitas"); }
// Static method /// <summary> /// Finds one pinpad and connects to it (connection is not closed). /// </summary> /// <param name="enableWifi">Whether Wi-Fi pinpads shall be searched.</param> /// <param name="stoneCode">Stone Code.</param> /// <returns>Returns the first pinpad found.</returns> public static IPinpadConnection GetFirst(bool enableWifi = false, string stoneCode = "StoneCode") { IPinpadConnection conn = CrossPlatformController.PinpadFinder.Find(enableWifi, stoneCode); if (conn == null) { throw new PinpadNotFoundException(); } return(conn); }
public void Pinpad_GetValueInOptionsShortWithCircularBehavior_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadCommunication comm = new PinpadCommunication(conn); PinpadInfos infos = new PinpadInfos(comm); IPinpadDisplay display = new PinpadDisplay(comm); PinpadKeyboard key = new PinpadKeyboard(comm, infos, display); key.DataPicker.GetValueInOptions("Menu", true, 1, 2, 3); }
public void PinpadDisplay_Construction_ShouldNotReturnNull() { // Arrange IPinpadConnection connectionStub = Mock.Of <IPinpadConnection>(); PinpadCommunication comm = new PinpadCommunication(connectionStub); // Act PinpadDisplay display = new PinpadDisplay(comm); // Assert Assert.IsNotNull(display); }
// Constructor: /// <summary> /// Constructor /// </summary> /// <param name="pinpadConnection">Connection with Pinpad device</param> public PinpadCommunication(IPinpadConnection pinpadConnection) { if (pinpadConnection == null) { throw new ArgumentNullException("pinpadConnection cannot be null."); } // To change pinpad comm timeout this.Connection = pinpadConnection; this.Connection.ReadTimeout = NON_BLOCKING_TIMEOUT; this.Connection.WriteTimeout = NON_BLOCKING_TIMEOUT; }
public void PrintImage_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); facade.Printer.AddLogo() .AppendLine(PrinterAlignmentCode.Center, PrinterFontSize.Big, "Testando {0}", "Ceres") .Print(); }
public void GetValueInOptionsString_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); string value = facade.Keyboard.DataPicker.GetValueInOptions( "Pokemon", false, "Bulbasaur", "Charmander", "Squirtle"); Debug.WriteLine(value); }
public void GetNumericValue_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); Nullable <int> value = facade.Keyboard.DataPicker.GetNumericValue( "Data Picker", false, 0, 5); Debug.WriteLine(value.Value); facade.Communication.ClosePinpadConnection("Carnaval 2017"); }
public void PinpadTable_Construction_ShouldNotReturnNull_IfParametersAreCorrect() { // Arrange IPinpadConnection conn = Mock.Of <IPinpadConnection>(); Stubs.PinpadCommunicationStub pinpadCommunicationStub = new Stubs.PinpadCommunicationStub(); // Act PinpadTable table = new PinpadTable(pinpadCommunicationStub); // Assert Assert.IsNotNull(table); }
public void OPN_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadCommunication comm = new PinpadCommunication(conn); OpnRequest opn = new OpnRequest(); OpnResponse opnResp = comm.SendRequestAndReceiveResponse <OpnResponse>(opn); DspRequest dsp = new DspRequest(); dsp.DSP_MSG.Value = new SimpleMessageProperty("ola"); GenericResponse r = comm.SendRequestAndReceiveResponse <GenericResponse>(dsp); }
public void PinpadInfo_GetDukptSerialNumber_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); for (int i = 1; i <= 21; i++) { Debug.WriteLine("{0} | DES | {1}", i, facade.Infos .GetDukptSerialNumber(i, CryptographyMode.DataEncryptionStandard)); Debug.WriteLine("{0} | 3DES | {1}", i, facade.Infos .GetDukptSerialNumber(i, CryptographyMode.TripleDataEncryptionStandard)); } }
public void OnePinpadFind_with_portName_test() { for (int i = 0; i < 5; i++) { IPinpadConnection conn = PinpadConnectionProvider.GetAt("COM27"); PinpadFacade facade = new PinpadFacade(conn); bool displayStatus = facade.Display.ShowMessage( "YAY! ^-^", (i + 1).ToString(), DisplayPaddingType.Center); facade.Communication .ClosePinpadConnection("Fechando conexao (" + (i + 1).ToString() + ")"); } }
/// <summary> /// Search in all available serial ports for a pinpad connection. /// </summary> /// <returns>The serial port name of pinpad if found, or null otherwise.</returns> public static string SearchPinpadPort() { // Search for a pinpad: IPinpadConnection connection = CrossPlatformController.PinpadFinder.Find(); // If connection is null, then none pinpad was found. if (connection == null) { return(null); } // Otherwise, closes the connection (because the method must only return the pinpad port, not a connection): connection.Close(); return(connection.ConnectionName); }
/// <summary> /// Search for a pinpad attached to <param name="connectionName"/>. /// </summary> /// <param name="stoneCode">Stone Code.</param> /// <returns>Returns the pinpad found.</returns> /// <exception cref="PinpadNotFoundException">If none pinpad were found at the port specified.</exception> public static IPinpadConnection GetAt(string connectionName, string stoneCode = "StoneCode") { IPinpadConnection connection = null; try { // Open connection with serial port or Pinpad Wi-Fi: connection = CrossPlatformController.PinpadFinder.Find(connectionName, stoneCode); } catch (IOException) { throw new PinpadNotFoundException(string.Format("None pinpad found at {0}.", connectionName), connectionName); } return(connection); }
public void GetValueInOptionsShort_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); Nullable <short> value = facade.Keyboard.DataPicker.GetValueInOptions( "Parcelas", false, 2, 3, 4, 5, 6); Debug.WriteLine(value.Value); }
public void UpdateService_test() { IPinpadConnection conn = PinpadConnectionProvider.GetAt("192.168.1.106"); if (conn != null) { IPinpadFacade pinpad = new PinpadFacade(conn); bool isLoaded = pinpad.UpdateService.Load( System.IO.Path.Combine( @"C:\Users\ccarvalho\Desktop\update-cmd", "StonePinpadWifi(v1.1.1).zip")); pinpad.UpdateService.Update(); } }
public void Keyboard_GetAmount_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade pinpad = new PinpadFacade(conn); Nullable <decimal> amount = pinpad.Keyboard.GetAmount(AmountCurrencyCode.Yen); if (amount.HasValue) { Debug.WriteLine("Valor digitado: " + amount.Value); } else { Debug.WriteLine("Não foi possível ler o valor."); } }
public void PinpadTransaction_ReadCard_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); TransactionType trnxType = TransactionType.Undefined; facade.TransactionService.EmvTable.UpdatePinpad(false); CardEntry card = facade.TransactionService.ReadCard( TransactionType.Debit, 0.1m, out trnxType, CardBrandMocker.Mock()); facade.TransactionService.ReadPassword( 0.1m, card.PrimaryAccountNumber, CardType.Emv); Assert.IsNotNull(card); }
public void Keyboard_getNumber_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); facade.Display.ShowMessage("ola", "tudo bom?", DisplayPaddingType.Center); string pump = facade.Keyboard.GetNumericInput( FirstLineLabelCode.TypeNumber, SecondLineLabelCode.GasPump, 1, 15, 15); if (pump == null) { Debug.WriteLine("Nao foi possivel ler um valor. Time out ou cancelamento."); } else { Debug.WriteLine("Valor digitado: " + pump); } }
public void Gertec_EX07_test() { // testes: //this.mockedPinpadConnection = new MockedPinpadConnection(); // prod: IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadCommunication comm = new PinpadCommunication(conn); GciGertecRequest request = new GciGertecRequest(); request.NumericInputType.Value = KeyboardNumberFormat.Decimal; request.TextInputType.Value = KeyboardTextFormat.None; request.LabelFirstLine.Value = FirstLineLabelCode.TypeNumber; request.LabelSecondLine.Value = SecondLineLabelCode.GasPump; request.MaximumCharacterLength.Value = 1; request.MinimumCharacterLength.Value = 10; request.TimeOut.Value = 60; request.TimeIdle.Value = 0; Debug.WriteLine(request.CommandString); GertecEx07Response response = comm .SendRequestAndReceiveResponse <GertecEx07Response>(request); if (response != null) { Debug.WriteLine("Response status: " + response.RSP_STAT.Value); Debug.WriteLine("Value typed: " + response.RSP_RESULT.Value); } else { Debug.WriteLine("Resposta nula. Cancelamento ou timeout."); } }
public void PrintText_test() { IPinpadConnection conn = PinpadConnectionProvider.GetFirst(); PinpadFacade facade = new PinpadFacade(conn); facade.Printer.AddLogo() .AppendLine(PrinterAlignmentCode.Center, PrinterFontSize.Small, "Credenciadora Banco Pan") .AppendLine(PrinterAlignmentCode.Center, PrinterFontSize.Small, "Via Estabelecimento") .AppendLine(PrinterAlignmentCode.Center, PrinterFontSize.Medium, "MASTERCARD - DEBITO A VISTA") .AppendLine(PrinterAlignmentCode.Center, PrinterFontSize.Medium, "525663******6251") .AddSeparator() .AppendLine(PrinterAlignmentCode.Center, PrinterFontSize.Medium, "MICROTEF TESTE") .AppendLine(PrinterAlignmentCode.Left, PrinterFontSize.Small, "CNPJ: 12.345.678/0001-90") .AppendLine(PrinterAlignmentCode.Left, PrinterFontSize.Small, "AID: A0000000001234 - ARQC: 12345678901234567") .AppendLine(PrinterAlignmentCode.Left, PrinterFontSize.Small, facade.Infos.SerialNumber) .AppendLine(PrinterAlignmentCode.Left, PrinterFontSize.Small, "StoneId: 1234567890123456") .AppendLine(PrinterAlignmentCode.Left, PrinterFontSize.Medium, "12/12/2016 16:19") .AddSeparator() .AppendLine(PrinterAlignmentCode.Left, PrinterFontSize.Medium, "CARVALHO/CERES R") .AppendLine(PrinterAlignmentCode.Left, PrinterFontSize.Big, "Valor: R$ 10,00") .AppendLine() .AddQrCode(PrinterAlignmentCode.Center, "1234567890123456") .Print(); }
/// <summary> /// Creates all pinpad adapters. /// </summary> /// <param name="pinpadConnection">Pinpad connection.</param> public PinpadFacade(IPinpadConnection pinpadConnection) { this.Connection = pinpadConnection; }
public void Setup() { this.PinpadFacadeMock = Mock.Of <IPinpadFacade>(); this.ConnectionStub = new Stubs.PinpadConnectionStub(); }