/// <summary> /// Create a <see cref="DataPickerKeys"/> based on the pin pad information. /// </summary> /// <param name="infos">Pinpad informarions.</param> /// <returns>Corresponding <see cref="DataPickerKeys"/> to pinpad.</returns> internal static DataPickerKeys GetUpAndDownKeys(this IPinpadInfos infos) { if (infos.ManufacturerName != null && infos.Model != null) { // Gertec PPC920 if (infos.ManufacturerName.ToUpper().Contains(Gertec) && infos.Model.ToUpper().Contains(Ppc920)) { return(new DataPickerKeys { UpKey = PinpadKeyCode.Function3, DownKey = PinpadKeyCode.Function4 }); } // Verifone Vx 820 else if (infos.ManufacturerName.ToUpper().Contains(Verifone) && infos.Model.ToUpper().Contains(Vx820)) { return(new DataPickerKeys { UpKey = PinpadKeyCode.Function1, DownKey = PinpadKeyCode.Function3 }); } // Ingenico iPP320PPC920 else if (infos.ManufacturerName.ToUpper().Contains(Ingenico) && infos.Model.ToUpper().Contains(Ipp320)) { return(new DataPickerKeys { UpKey = PinpadKeyCode.Function3, DownKey = PinpadKeyCode.Function2 }); } } return(new DataPickerKeys()); // Gertec use by default. }
public void UpdateService_Creation_ShouldThrowException_IfPinpadInformationIsNull() { // Assert Assert.Throws <ArgumentNullException>(() => { // Arrange IPinpadInfos infos = null; IPinpadCommunication comm = new Stubs.PinpadCommunicationStub(); // Act PinpadUpdateService pinpadUpdateService = new PinpadUpdateService(infos, comm); }); }
// ctor: /// <summary> /// Creates the instance mandatorily with a <see cref="IPinpadInfos"/> and <see cref="IPinpadCommunication"/>. /// Otherwise, throws exception. /// </summary> /// <param name="pinpadInformation">Informations about the device.</param> /// <param name="pinpadCommunication">Responsible for sending and receiving commands to and from the /// pinpad.</param> /// <exception cref="ArgumentException">If any parameters are null.</exception> public PinpadUpdateService(IPinpadInfos pinpadInformation, IPinpadCommunication pinpadCommunication) { if (pinpadInformation == null) { throw new ArgumentNullException(nameof(pinpadInformation)); } if (pinpadCommunication == null) { throw new ArgumentNullException(nameof(pinpadInformation)); } this.PinpadInfos = pinpadInformation; this.PinpadCommunication = pinpadCommunication; }
public void DataPickerKeysFactory_GetUpAndDownKeys_ShouldReturnVerifoneKeys_WhenVerifoneInfosArePassed() { // Arrange var mock = new Mock <IPinpadInfos>(); mock.SetupGet(x => x.ManufacturerName).Returns("VERIFONE"); mock.SetupGet(x => x.Model).Returns("VX820"); IPinpadInfos infos = mock.Object; // Act DataPickerKeys keys = infos.GetUpAndDownKeys(); // Assert Assert.IsNotNull(keys); Assert.AreEqual(PinpadKeyCode.Function1, keys.UpKey); Assert.AreEqual(PinpadKeyCode.Function3, keys.DownKey); }
// Constructor /// <summary> /// Build a data picker with a reference to keyboard and display. /// </summary> /// <param name="keyboard"><seealso cref="IPinpadKeyboard"/> implementation.</param> /// <param name="infos"><seealso cref="IPinpadInfos"/> implementation.</param> /// <param name="display"><seealso cref="IPinpadDisplay"/> implementation.</param> public DataPicker(IPinpadKeyboard keyboard, IPinpadInfos infos, IPinpadDisplay display) { this._keyboard = keyboard; this._display = display; this.DataPickerKeys = infos.GetUpAndDownKeys(); }
/// <summary> /// Creates an instance of <see cref="IngenicoPinpadPrinter"/> with all it's properties. /// </summary> /// <param name="communication">Pinpad communication service.</param> /// <param name="infos">Real time pinpad information.</param> public IngenicoPinpadPrinter(IPinpadCommunication communication, IPinpadInfos infos) { this.Communication = communication; this.PinpadInformation = infos; this.ItemsToPrint = new Collection <PrinterItem>(); }
// Constructor: /// <summary> /// Default constructor. /// </summary> /// <param name="communication">Pinpad communication, through which is possible to communicate with the pinpad.</param> /// <param name="infos">Pinpad informations.</param> /// <param name="display">Pinpad display, through which is possible to use with the display operations in data picker.</param> public PinpadKeyboard(PinpadCommunication communication, IPinpadInfos infos, IPinpadDisplay display) { this.Communication = communication; this.Informations = infos; this.DataPicker = new DataPicker(this, infos, display); }