Exemplo n.º 1
0
        public void Test7()
        {
            SDM.LMS.ClearDB();

            SDM.LMS.RegisterUser("p1", "p1", "p1", "p1", "p1", false);
            SDM.LMS.RegisterUser("p2", "p2", "p2", "p2", "p2", false);
            SDM.LMS.RegisterUser("lb", "lb", "lb", "lb", "lb", true);
            Student   p1 = new Student("p1");
            Student   p2 = new Student("p2");
            Librarian lb = new Librarian("lb");

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

            lb.AddAV("b1", "B", 0, 2, "");
            DocClass b1 = new DocClass("b1");

            p1.CheckOut(b1.ID);
            p2.CheckOut(b1.ID);

            Debug.Assert(SDM.LMS.GetUser(lb.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p1.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p2.PersonID) != null);
            Debug.Assert(SDM.LMS.GetDoc(b1.ID) != null);
            Debug.Assert(b1.Quantity == 0);
            Debug.Assert(SDM.LMS.GetUserBooks(p1.PersonID, 7, "").Count == 1);
            Debug.Assert(SDM.LMS.GetUserBooks(p2.PersonID, 7, "").Count == 1);
        }
Exemplo n.º 2
0
        public void Test5()
        {
            SDM.LMS.ClearDB();

            SDM.LMS.RegisterUser("st", "st", "st", "st", "st", false);
            SDM.LMS.RegisterUser("st1", "st1", "st1", "st1", "st1", false);
            SDM.LMS.RegisterUser("st2", "st2", "st2", "st2", "st2", false);
            SDM.LMS.RegisterUser("lb", "lb", "lb", "lb", "lb", true);
            Student   st  = new Student("st");
            Student   st1 = new Student("st1");
            Student   st2 = new Student("st2");
            Librarian lb  = new Librarian("lb");

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

            lb.AddAV("a", "a", 0, 2, "");
            DocClass a = new DocClass("a");

            st.CheckOut(a.ID);
            st1.CheckOut(a.ID);
            st2.CheckOut(a.ID);

            Debug.Assert(SDM.LMS.GetUser(lb.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(st.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(st1.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(st2.PersonID) != null);
            Debug.Assert(SDM.LMS.GetDoc(a.ID) != null);
            Debug.Assert(a.Quantity == 0);
            Debug.Assert(SDM.LMS.GetUserBooks(st.PersonID, 7, "").Count == 1);
            Debug.Assert(SDM.LMS.GetUserBooks(st1.PersonID, 7, "").Count == 1);
            Debug.Assert(SDM.LMS.GetUserBooks(st2.PersonID, 7, "").Count == 0);
        }
Exemplo n.º 3
0
        private void OnAddBookClick(object sender, RoutedEventArgs e)
        {
            Librarian currentUser = (Librarian)SDM.CurrentUser;
            int       price       = Convert.ToInt32(PriceTB.Text);
            int       quantity    = Convert.ToInt32(CopiesTB.Text);

            currentUser.AddAV
            (
                TitleTB.Text,
                AutorsTB.Text,
                price,
                quantity,
                TagsTB.Text
            );

            _previousPage.UpdateTable();
            Close();
        }
Exemplo n.º 4
0
        public void Initial()
        {
            SDM.LMS.ClearDB();

            SDM.LMS.RegisterUser("lb", "lb", "lb", "lb", "lb", true);
            Librarian lb = new Librarian("lb");

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

            lb.AddBook
            (
                "Introduction to Algorithms",
                "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein",
                "MIT Press",
                2009,
                "Third Edition",
                "Alghorithm techniques and design",
                5000,
                false,
                3,
                ""
            );
            lb.AddBook
            (
                "Design Patterns: Elements of Reusable Object-Oriented Software",
                "Erich Gamma, Ralph Johnson, John Vlissides, Richard Helm",
                "Addison-Wesley Professional",
                2003,
                "First Edition",
                "Programm patterns, how to programm well w/o headache",
                1700,
                true,
                3,
                ""
            );
            lb.AddAV("Null References: The Billion Dollar Mistake", "Tony Hoare", 700, 2, "");
            DocClass d1 = new DocClass("Introduction to Algorithms");
            DocClass d2 = new DocClass("Design Patterns: Elements of Reusable Object-Oriented Software");
            DocClass d3 = new DocClass("Null References: The Billion Dollar Mistake");

            lb.RegisterUser("p1", "p1", "p1", "Via Margutta, 3", "30001", false);
            lb.RegisterUser("p2", "p2", "p2", "Via Sacra, 13", "30002", false);
            lb.RegisterUser("p3", "p3", "p3", "Via del Corso, 22", "30003", false);
            lb.RegisterUser("s", "s", "s", "s", "s", false);
            lb.RegisterUser("v", "v", "v", "v", "v", false);
            Student p1 = new Student("p1");
            Student p2 = new Student("p2");
            Student p3 = new Student("p3");
            Student s  = new Student("s");
            Student v  = new Student("v");

            lb.ModifyUser(p1.PersonID, p1.Name, p1.Adress, p1.PhoneNumber, 4);
            lb.ModifyUser(p2.PersonID, p2.Name, p2.Adress, p2.PhoneNumber, 4);
            lb.ModifyUser(p3.PersonID, p3.Name, p3.Adress, p3.PhoneNumber, 4);
            lb.ModifyUser(v.PersonID, v.Name, v.Adress, v.PhoneNumber, 3);

            Debug.Assert(SDM.LMS.GetDoc(d1.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(d2.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(d3.ID) != null);

            Debug.Assert(d1.Quantity == 3);
            Debug.Assert(d2.Quantity == 3);
            Debug.Assert(d3.Quantity == 2);

            Debug.Assert(SDM.LMS.GetUser(p1.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p2.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p3.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(s.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(v.PersonID) != null);
        }
Exemplo n.º 5
0
        public void Test11()
        {
            SDM.LMS.ClearDB();

            SDM.LMS.RegisterUser("lb", "lb", "lb", "lb", "lb", true);
            Librarian lb = new Librarian("lb");

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

            lb.AddBook
            (
                "Introduction to Algorithms",
                "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein",
                "MIT Press",
                2009,
                "Third Edition",
                "Alghorithm techniques and design",
                1800,
                false,
                3,
                ""
            );
            lb.AddBook
            (
                "Design Patterns: Elements of Reusable Object-Oriented Software",
                "Erich Gamma, Ralph Johnson, John Vlissides, Richard Helm",
                "Addison-Wesley Professional",
                2003,
                "First Edition",
                "Programm patterns, how to programm well w/o headache",
                2000,
                true,
                2,
                ""
            );
            lb.AddBook
            (
                "The Mythical Man-month",
                "Brooks,Jr., Frederick P",
                "Addison-Wesley Longman Publishing Co., Inc.",
                1995,
                "Second edition",
                "How to do everything and live better",
                800,
                false,
                1,
                ""
            );
            lb.AddAV("Null References: The Billion Dollar Mistake", "Tony Hoare", 400, 1, "");
            lb.AddAV("Information Entropy", "Claude Shannon", 700, 1, "");
            DocClass b1  = new DocClass("Introduction to Algorithms");
            DocClass b2  = new DocClass("Design Patterns: Elements of Reusable Object-Oriented Software");
            DocClass b3  = new DocClass("The Mythical Man-month");
            DocClass av1 = new DocClass("Null References: The Billion Dollar Mistake");
            DocClass av2 = new DocClass("Information Entropy");

            lb.RegisterUser("Sergey Afonso", "Sergey Afonso", "Sergey Afonso", "Via Margutta, 3", "30001", false);
            lb.RegisterUser("Nadia Teixeira", "Nadia Teixeira", "Nadia Teixeira", "Via Sacra, 13", "30002", false);
            lb.RegisterUser("Elvira Espindola", "Elvira Espindola", "Elvira Espindola", "Via del Corso, 22", "30003", false);
            Student p1 = new Student("Sergey Afonso");
            Student p2 = new Student("Nadia Teixeira");
            Student p3 = new Student("Elvira Espindola");

            lb.ModifyUser(p1.PersonID, p1.Name, p1.Adress, p1.PhoneNumber, p1.UserType + 1);

            Debug.Assert(SDM.LMS.GetDoc(b1.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(b2.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(b3.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(av1.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(av2.ID) != null);

            Debug.Assert(b1.Quantity == 3);
            Debug.Assert(b2.Quantity == 2);
            Debug.Assert(b3.Quantity == 1);
            Debug.Assert(av1.Quantity == 1);
            Debug.Assert(av2.Quantity == 1);

            Debug.Assert(SDM.LMS.GetUser(p1.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p2.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p3.PersonID) != null);
        }