public void FourOrders200CentWithDonation_01() { int[] coins = { 0, 0, 0, 3, 3, 3 }; int[] returnCoinsExpected = { 0, 0, 0, 0, 0, 0 }; // 1 * 100 und 1* 50 cent string[] productNames = { "Kaffee", "Tee", "Suppe", "Milch" }; Logic.CoffeeSlotMachine coffeeSlotMachine = new Logic.CoffeeSlotMachine(coins, productNames); coffeeSlotMachine.InsertCoin(200); coffeeSlotMachine.SelectProduct("Kaffee", out int donation); Assert.IsTrue(CompareArrays(coffeeSlotMachine.EmptyEjection(out _), new int[] { 0, 0, 0, 1, 1, 0 }), "Es bleiben keine passenden Münzen mehr übrig"); Assert.AreEqual(0, donation, "Kein Spende"); coffeeSlotMachine.InsertCoin(200); coffeeSlotMachine.SelectProduct("Kaffee", out donation); Assert.IsTrue(CompareArrays(coffeeSlotMachine.EmptyEjection(out _), new int[] { 0, 0, 0, 1, 1, 0 }), "Es bleiben keine passenden Münzen mehr übrig"); Assert.AreEqual(0, donation, "Kein Spende"); coffeeSlotMachine.InsertCoin(200); coffeeSlotMachine.SelectProduct("Kaffee", out donation); Assert.IsTrue(CompareArrays(coffeeSlotMachine.EmptyEjection(out _), new int[] { 0, 0, 0, 1, 1, 0 }), "Es bleiben keine passenden Münzen mehr übrig"); Assert.AreEqual(0, donation, "Kein Spende"); coffeeSlotMachine.InsertCoin(200); bool ok = coffeeSlotMachine.SelectProduct("Kaffee", out donation); Assert.IsTrue(ok, "SelectProduct sollte funktionieren"); Assert.IsTrue(CompareArrays(coffeeSlotMachine.EmptyEjection(out _), new int[] { 0, 0, 0, 0, 0, 0 }), "Es bleiben keine passenden Münzen mehr übrig"); Assert.AreEqual(150, donation, "Kein Retourgeld mehr"); Assert.AreEqual(7, coffeeSlotMachine.CoinsInDepot, "7 * 200 cent"); }
public void NormalOrder_01() { int[] coins = { 1, 2, 3, 4, 5, 6 }; int[] returnCoinsExpected = { 0, 0, 0, 1, 0, 0 }; // 1* 50 cent string[] productNames = { "Kaffee", "Tee", "Suppe", "Milch" }; Logic.CoffeeSlotMachine coffeeSlotMachine = new Logic.CoffeeSlotMachine(coins, productNames); bool ok = coffeeSlotMachine.InsertCoin(100); Assert.IsTrue(ok, "InsertCoin sollte funktionieren"); ok = coffeeSlotMachine.SelectProduct("Kaffee", out int donation); Assert.IsTrue(ok, "SelectProduct sollte funktionieren"); Assert.IsTrue(CompareArrays(coffeeSlotMachine.EmptyEjection(out _), returnCoinsExpected), "Arrays mit Retourgeld sind nicht gleich"); Assert.AreEqual(0, donation, "Es konnte das gesamte Restgeld zurückgegeben werden"); Assert.AreEqual(21, coffeeSlotMachine.CoinsInDepot, "100 cent hinein und 50 cent hinaus"); }
public void MoreCoinsAndCancel_01() { int[] returnCoins; int[] returnCoinsExpected = { 0, 1, 2, 0, 0, 0 }; int[] coins = { 1, 2, 3, 4, 5, 6 }; string[] productNames = { "Kaffee", "Tee", "Suppe", "Milch" }; Logic.CoffeeSlotMachine coffeeSlotMachine = new Logic.CoffeeSlotMachine(coins, productNames); bool ok = coffeeSlotMachine.InsertCoin(20); Assert.IsTrue(ok, "20 ist eine gültige Münze"); ok = coffeeSlotMachine.InsertCoin(20); Assert.IsTrue(ok, "20 ist eine gültige Münze"); ok = coffeeSlotMachine.InsertCoin(10); Assert.IsTrue(ok, "10 ist eine gültige Münze"); Assert.AreEqual(21, coffeeSlotMachine.CoinsInDepot, "Münzen wurden noch nicht übernommen"); coffeeSlotMachine.CancelOrder(); returnCoins = coffeeSlotMachine.EmptyEjection(out _); Assert.IsTrue(CompareArrays(returnCoins, returnCoinsExpected), "Stornierte Münzen stimmen nicht"); Assert.AreEqual(21, coffeeSlotMachine.CoinsInDepot, "Alter Zustand bleibt erhalten"); }
public void FourOrders200CentWithLessDonation_01() { int[] coins = { 2, 3, 4, 3, 3, 3 }; int[] returnCoinsExpected = { 2, 3, 4, 0, 0, 0 }; string[] productNames = { "Kaffee", "Tee", "Suppe", "Milch" }; Logic.CoffeeSlotMachine coffeeSlotMachine = new Logic.CoffeeSlotMachine(coins, productNames); coffeeSlotMachine.InsertCoin(200); coffeeSlotMachine.SelectProduct("Kaffee", out _); coffeeSlotMachine.InsertCoin(200); coffeeSlotMachine.SelectProduct("Kaffee", out _); coffeeSlotMachine.InsertCoin(200); coffeeSlotMachine.SelectProduct("Kaffee", out _); coffeeSlotMachine.InsertCoin(200); bool ok = coffeeSlotMachine.SelectProduct("Kaffee", out int donation); Assert.IsTrue(ok, "SelectProduct sollte funktionieren"); Assert.IsTrue(CompareArrays(coffeeSlotMachine.EmptyEjection(out _), returnCoinsExpected), "Ganzes Kleingeld wurde zurückgegeben"); Assert.AreEqual(30, donation, "30 cent fehlen beim retourgeld"); Assert.AreEqual(7, coffeeSlotMachine.CoinsInDepot, "7 * 200 cent"); }