public void TestTraineeProcessingTime() { var cashier = new CashierTrainee(0); int completionTime = cashier.EnqueueCustomer(new CustomerA(0, 2)); Assert.AreEqual(4, completionTime); cashier.EnqueueCustomer(new CustomerB(1, 3)); cashier.EnqueueCustomer(new CustomerA(1, 1)); completionTime = cashier.EnqueueCustomer(new CustomerB(3, 10)); Assert.AreEqual(29, completionTime); }
public void TestBChoosingEmptyLine() { var c1 = new Cashier(1); c1.EnqueueCustomer(new CustomerA(0, 10)); var c2 = new Cashier(2); c2.EnqueueCustomer(new CustomerB(0, 2)); var t = new CashierTrainee(3); var cashiers = new HashSet<ICashier> {c1, c2, t}; var b = new CustomerB(1, 10); var chosenCashier = b.ChooseCashier(cashiers); ; Assert.AreEqual(t, chosenCashier); }
public void TestAChoosingShortestLine() { var c1 = new Cashier(1); c1.EnqueueCustomer(new CustomerA(1, 10)); c1.EnqueueCustomer(new CustomerB(2, 100)); c1.EnqueueCustomer(new CustomerA(3, 8)); var c2 = new Cashier(2); c2.EnqueueCustomer(new CustomerB(2, 10)); c2.EnqueueCustomer(new CustomerB(2, 15)); var c3 = new CashierTrainee(3); c3.EnqueueCustomer(new CustomerA(1, 9999)); var cashiers = new HashSet<ICashier> {c1, c2, c3}; var c = new CustomerA(3, 1); var chosenCashier = c.ChooseCashier(cashiers); Assert.AreEqual(c3, chosenCashier); }
public void TestBChoosingLineWithFewestItemsLeftForLastPerson() { var c1 = new CashierTrainee(1); c1.EnqueueCustomer(new CustomerA(1, 10)); c1.EnqueueCustomer(new CustomerB(2, 100)); c1.EnqueueCustomer(new CustomerA(3, 8)); var c2 = new Cashier(2); c2.EnqueueCustomer(new CustomerB(2, 10)); c2.EnqueueCustomer(new CustomerB(2, 15)); var c3 = new Cashier(3); c3.EnqueueCustomer(new CustomerA(1, 18)); var cashiers = new HashSet<ICashier> {c1, c2, c3}; var c = new CustomerB(4, 999); var chosenCashier = c.ChooseCashier(cashiers); Assert.AreEqual(c1, chosenCashier); }