private static void InitializeCoinDispenser() { DeviceCollection coinDispenserList = CoinDispenserDeviceCollection; if (coinDispenserList.Count > 0) { try { DeviceInfo coinDispenser = GetActiveDeviceInfo(coinDispenserList, "CoinDispenserName", true); if (coinDispenser != null) { activeCoinDispenser = (CoinDispenser)explorer.CreateInstance(coinDispenser); activeCoinDispenser.Open(); activeCoinDispenser.Claim(1000); activeCoinDispenser.DeviceEnabled = true; } } catch (PosControlException) { // Log error and set the active to nil activeCoinDispenser = null; Logger.Error("InitializePosDevices", Strings.InitializationException); } } }
public void GetAllCoins() { decimal balance1 = 1.55m; int expectedQuarters1 = 6; int expectedDimes1 = 0; int expectedNickels1 = 1; decimal balance2 = .20m; int expectedQuarters2 = 0; int expectedDimes2 = 2; int expectedNickels2 = 0; decimal balance3 = 2.05m; int expectedQuarters3 = 8; int expectedDimes3 = 0; int expectedNickels3 = 1; CoinDispenser.DispenseChange(balance1); Assert.AreEqual(expectedQuarters1, CoinDispenser.quarterReturn, $"Quarters returned is {CoinDispenser.quarterReturn}, it should be {expectedQuarters1}."); Assert.AreEqual(expectedDimes1, CoinDispenser.dimeReturn, $"Dimes returned {CoinDispenser.dimeReturn}, it should be {expectedDimes1}."); Assert.AreEqual(expectedNickels1, CoinDispenser.nickelReturn, $"Nickels returned {CoinDispenser.nickelReturn}, it should be {expectedNickels1}."); CoinDispenser.DispenseChange(balance2); Assert.AreEqual(expectedQuarters2, CoinDispenser.quarterReturn, $"Quarters returned is {CoinDispenser.quarterReturn}, it should be {expectedQuarters2}."); Assert.AreEqual(expectedDimes2, CoinDispenser.dimeReturn, $"Dimes returned {CoinDispenser.dimeReturn}, it should be {expectedDimes2}."); Assert.AreEqual(expectedNickels2, CoinDispenser.nickelReturn, $"Nickels returned {CoinDispenser.nickelReturn}, it should be {expectedNickels2}."); CoinDispenser.DispenseChange(balance3); Assert.AreEqual(expectedQuarters3, CoinDispenser.quarterReturn, $"Quarters returned is {CoinDispenser.quarterReturn}, it should be {expectedQuarters3}."); Assert.AreEqual(expectedDimes3, CoinDispenser.dimeReturn, $"Dimes returned {CoinDispenser.dimeReturn}, it should be {expectedDimes3}."); Assert.AreEqual(expectedNickels3, CoinDispenser.nickelReturn, $"Nickels returned {CoinDispenser.nickelReturn}, it should be {expectedNickels3}."); }
public override void SetOpened(bool opened) { if (_dispenser == null) { _dispenser = (CoinDispenser)PosCommon; } }
/// <summary> /// Gets the coin dispenser. /// </summary> /// <returns>Coin dispenser</returns> private static ICoinDispenser GetCoinDispenser() { ICoinDispenser dispenser = CoinDispenser.Initialise(); dispenser.SerialPortName = GetCOMPortName(); return(dispenser); }
public void GetNickelsTest() { decimal balance = .55m; int expectedNickels = 1; CoinDispenser.DispenseChange(balance); Assert.AreEqual(expectedNickels, CoinDispenser.nickelReturn, $"GetNickels returned {CoinDispenser.nickelReturn}, it should be {expectedNickels}."); }
public void GetDimesTest() { decimal balance = .70m; int expectedDimes = 2; CoinDispenser.DispenseChange(balance); Assert.AreEqual(expectedDimes, CoinDispenser.dimeReturn, $"GetDimes returned {CoinDispenser.dimeReturn}, it should be {expectedDimes}."); }
public void GetQuartersTest() { decimal balance = .75m; int expectedQuarters = 3; CoinDispenser.DispenseChange(balance); Assert.AreEqual(expectedQuarters, CoinDispenser.quarterReturn, $"GetQuarters returned {CoinDispenser.quarterReturn}, it should be {expectedQuarters}."); }
public void CheckFor0OrNegativeBalance() { decimal balance = 0; Assert.AreEqual(false, CoinDispenser.DispenseChange(balance), $"{balance} is 0, DispenseChange should return false."); decimal balance2 = -15; Assert.AreEqual(false, CoinDispenser.DispenseChange(balance2), $"Negative banace should return false."); }
public void GivenIHaveACoinDispenserWithDenominationOf(params int[] denomination) { _paymentAccepted = false; _exceptionCaught = null; _CoinReturnAlgorithmMock = new Mock <ICoinReturnAlgorithm>(); _loggerMock = new Mock <ILogger <CoinDispenser> >(); var settingsMock = new Mock <IOptions <CoinSettings> >(); settingsMock.Setup(x => x.Value).Returns(new CoinSettings { Denomination = denomination, Scale = 2 }); _coinDispenser = new CoinDispenser(_CoinReturnAlgorithmMock.Object, _loggerMock.Object, settingsMock.Object); }