Beispiel #1
0
        public void getPriceArrayTest()
        {
            TripDB tripDB   = new TripDB();
            int    tripID   = tripDB.addTrip(1);
            int    payerId1 = tripDB.addPayer(tripID, 0, 3);

            tripDB.addPrice(payerId1, 0, 1.0);
            tripDB.addPrice(payerId1, 1, 2.0);
            tripDB.addPrice(payerId1, 2, 3.0);
            double[] priceArray = tripDB.getPriceArray(payerId1);
            double[] input      = new double[] { 1.0, 2.0, 3.0 };
            CollectionAssert.AreEqual(input, priceArray);
        }
Beispiel #2
0
        public void getPayersRemainTest()
        {
            TripDB tripDB   = new TripDB();
            int    tripID   = tripDB.addTrip(3);
            int    payerId1 = tripDB.addPayer(tripID, 0, 1);
            int    payerId2 = tripDB.addPayer(tripID, 1, 1);
            int    payerId3 = tripDB.addPayer(tripID, 2, 1);

            tripDB.addPrice(payerId1, 0, 5.0);
            tripDB.addPrice(payerId2, 0, 10.0);
            tripDB.addPrice(payerId3, 0, 15.0);
            double[] remains = tripDB.getPayersRemain(tripID);
            double[] input   = new double[] { 5.0, 0, -5.0 };
            CollectionAssert.AreEqual(input, remains);
        }
Beispiel #3
0
        public void getTripAverageTest()
        {
            TripDB tripDB   = new TripDB();
            int    tripID   = tripDB.addTrip(3);
            int    payerId1 = tripDB.addPayer(tripID, 0, 1);
            int    payerId2 = tripDB.addPayer(tripID, 1, 1);
            int    payerId3 = tripDB.addPayer(tripID, 2, 1);

            tripDB.addPrice(payerId1, 0, 5.0);
            tripDB.addPrice(payerId2, 0, 10.0);
            tripDB.addPrice(payerId3, 0, 15.0);
            double average = tripDB.getTripAverage(tripID);

            Assert.AreEqual(average, 10.0);
        }