Ejemplo n.º 1
0
        public void Test21()
        {
            Initial();
            int[]    timeCheat = { 05, 03, 2018 };
            DateTime Now       = new DateTime(2018, 04, 02);

            Faculty           p1 = new Faculty("p1");
            Student           s  = new Student("s");
            VisitingProfessor v  = new VisitingProfessor("v");

            DocClass d1 = new DocClass("Introduction to Algorithms");
            DocClass d2 = new DocClass("Design Patterns: Elements of Reusable Object-Oriented Software");

            p1.CheckOut(d1.ID, timeCheat);
            p1.CheckOut(d2.ID, timeCheat);
            s.CheckOut(d1.ID, timeCheat);
            s.CheckOut(d2.ID, timeCheat);
            v.CheckOut(d1.ID, timeCheat);
            v.CheckOut(d2.ID, timeCheat);

            Debug.Assert(SDM.LMS.OverdueTime(p1.PersonID, d1.ID, Now) == 0);
            Debug.Assert(SDM.LMS.OverdueTime(p1.PersonID, d2.ID, Now) == 0);
            Debug.Assert(SDM.LMS.GetUserFineForDoc(p1.PersonID, d1.ID, Now) == 0);
            Debug.Assert(SDM.LMS.GetUserFineForDoc(p1.PersonID, d2.ID, Now) == 0);

            Debug.Assert(SDM.LMS.OverdueTime(s.PersonID, d1.ID, Now) == 7);
            Debug.Assert(SDM.LMS.OverdueTime(s.PersonID, d2.ID, Now) == 14);
            Debug.Assert(SDM.LMS.GetUserFineForDoc(s.PersonID, d1.ID, Now) == 700);
            Debug.Assert(SDM.LMS.GetUserFineForDoc(s.PersonID, d2.ID, Now) == 1400);

            Debug.Assert(SDM.LMS.OverdueTime(v.PersonID, d1.ID, Now) == 21);
            Debug.Assert(SDM.LMS.OverdueTime(v.PersonID, d2.ID, Now) == 21);
            Debug.Assert(SDM.LMS.GetUserFineForDoc(v.PersonID, d1.ID, Now) == 2100);
            Debug.Assert(SDM.LMS.GetUserFineForDoc(v.PersonID, d2.ID, Now) == 1700);
        }
Ejemplo n.º 2
0
        public void Test23()
        {
            Initial();
            int[] timeCheat = { 31, 03, 2018 };

            Librarian         lb = new Librarian("lb");
            Faculty           p1 = new Faculty("p1");
            Student           s  = new Student("s");
            VisitingProfessor v  = new VisitingProfessor("v");

            admin.ModifyLibrarian(lb.PersonID, "lb", "lb", "lb", 2);

            DocClass d1 = new DocClass("Introduction to Algorithms");
            DocClass d2 = new DocClass("Design Patterns: Elements of Reusable Object-Oriented Software");

            p1.CheckOut(d1.ID, timeCheat);
            s.CheckOut(d2.ID, timeCheat);
            v.CheckOut(d2.ID, timeCheat);
            lb.OutstandingRequest(d2.ID);

            timeCheat = new int[] { 02, 04, 2018 };
            DateTime Now = new DateTime(2018, 04, 14);

            p1.RenewDoc(d1.ID, timeCheat);
            s.RenewDoc(d2.ID, timeCheat);
            v.RenewDoc(d2.ID, timeCheat);

            Debug.Assert(SDM.LMS.GetCheckout(p1.PersonID, d1.ID).TimeToBack.Day == 30);
            Debug.Assert(SDM.LMS.GetCheckout(s.PersonID, d2.ID).TimeToBack.Day == Now.Day);
            Now = new DateTime(2018, 04, 07);
            Debug.Assert(SDM.LMS.GetCheckout(v.PersonID, d2.ID).TimeToBack.Day == Now.Day);
        }
Ejemplo n.º 3
0
        public void Test25()
        {
            Initial();
            int[] dateCheat = { 02, 04, 2018 };

            Faculty           p1 = new Faculty("p1");
            Student           s  = new Student("s");
            VisitingProfessor v  = new VisitingProfessor("v");

            DocClass d3 = new DocClass("Null References: The Billion Dollar Mistake");

            p1.CheckOut(d3.ID, dateCheat);
            s.CheckOut(d3.ID, dateCheat);
            v.CheckOut(d3.ID, dateCheat);

            PriorityQueue <int> pq = SDM.LMS.LoadPQ(d3.ID);

            Debug.Assert(pq.Pop() == v.PersonID);
        }
Ejemplo n.º 4
0
        public void Test30()
        {
            Initial();

            Faculty           p1 = new Faculty("p1");
            VisitingProfessor v  = new VisitingProfessor("v");

            DocClass d1 = new DocClass("Introduction to Algorithms");

            p1.CheckOut(d1.ID, new int[] { 26, 03, 2018 });
            p1.RenewDoc(d1.ID, new int[] { 29, 03, 2018 });
            v.CheckOut(d1.ID, new int[] { 29, 03, 2018 });
            v.RenewDoc(d1.ID, new int[] { 30, 03, 2018 });

            List <CheckedOut> checkedOuts = SDM.LMS.GetCheckoutsList("p1");

            Debug.Assert(checkedOuts.First().CheckOutTime == 26);
            Debug.Assert(checkedOuts.First().DocumentCheckedOut == "Introduction to Algorithms");
            checkedOuts = SDM.LMS.GetCheckoutsList("v");
            Debug.Assert(checkedOuts.First().CheckOutTime == 5);
            Debug.Assert(checkedOuts.First().DocumentCheckedOut == "Introduction to Algorithms");
        }
Ejemplo n.º 5
0
        public void Test22()
        {
            Initial();
            int[] timeCheat = { 02, 04, 2018 };

            Faculty           p1 = new Faculty("p1");
            Student           s  = new Student("s");
            VisitingProfessor v  = new VisitingProfessor("v");

            DocClass d1 = new DocClass("Introduction to Algorithms");
            DocClass d2 = new DocClass("Design Patterns: Elements of Reusable Object-Oriented Software");

            p1.CheckOut(d1.ID, timeCheat);
            s.CheckOut(d2.ID, timeCheat);
            v.CheckOut(d2.ID, timeCheat);

            p1.RenewDoc(d1.ID, timeCheat);
            s.RenewDoc(d2.ID, timeCheat);
            v.RenewDoc(d2.ID, timeCheat);

            Debug.Assert(SDM.LMS.GetCheckout(p1.PersonID, d1.ID).TimeToBack.Day == 30);
            Debug.Assert(SDM.LMS.GetCheckout(s.PersonID, d2.ID).TimeToBack.Day == 16);
            Debug.Assert(SDM.LMS.GetCheckout(v.PersonID, d2.ID).TimeToBack.Day == 9);
        }
Ejemplo n.º 6
0
        public void Test37()
        {
            Test34();

            Faculty           p1  = new Faculty("p1");
            Faculty           p2  = new Faculty("p2");
            Student           s   = new Student("s");
            VisitingProfessor v   = new VisitingProfessor("v");
            Faculty           p3  = new Faculty("p3");
            Librarian         lb3 = new Librarian("lb3");

            DocClass d1 = new DocClass("d1");
            DocClass d2 = new DocClass("d2");
            DocClass d3 = new DocClass("d3");

            SDM.CurrentUser = p1;
            p1.CheckOut(d3.ID);

            SDM.CurrentUser = p2;
            p2.CheckOut(d3.ID);

            SDM.CurrentUser = s;
            s.CheckOut(d3.ID);

            SDM.CurrentUser = v;
            v.CheckOut(d3.ID);

            SDM.CurrentUser = p3;
            p3.CheckOut(d3.ID);

            SDM.CurrentUser = lb3;
            lb3.OutstandingRequest(d3.ID);

            Debug.Assert(d3.IsRequested);
            Debug.Assert(!SDM.LMS.ExistQueueForDoc(d3.ID));
        }