Exemplo n.º 1
0
        public void TestNonTraineeProcessingTime()
        {
            var cashier = new Cashier(0);
            int completionTime = cashier.EnqueueCustomer(new CustomerA(0, 2));
            Assert.AreEqual(2, completionTime);

            completionTime = cashier.EnqueueCustomer(new CustomerB(1, 5));
            Assert.AreEqual(6, completionTime);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void TestGetLineLength()
        {
            var cashier = new Cashier(0);
            cashier.EnqueueCustomer(new CustomerA(1, 10));
            cashier.EnqueueCustomer(new CustomerA(2, 5));
            int time3 = cashier.EnqueueCustomer(new CustomerB(2, 3));
            int completiontime = 2 + time3;
            Assert.AreEqual(19, completiontime);
            int lineLength = cashier.CalculateQueueLength(2);
            Assert.AreEqual(3, lineLength);

            lineLength = cashier.CalculateQueueLength(18);
            Assert.AreEqual(1, lineLength);
            lineLength = cashier.CalculateQueueLength(19);
            Assert.AreEqual(0, lineLength);

            lineLength = cashier.CalculateQueueLength(36);
            Assert.AreEqual(0, lineLength);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }