Exemple #1
0
        public void Test10()
        {
            SDM.LMS.ClearDB();

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

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

            lb.AddBook("b", "B", "B", 0, "B", "B", 0, false, 1, "");
            lb.AddBook("a", "A", "A", 0, "A", "A", 0, false, 0, "");
            DocClass b = new DocClass("b");
            DocClass a = new DocClass("a");

            st.CheckOut(a.ID);
            st.CheckOut(b.ID);

            Debug.Assert(SDM.LMS.GetUser(lb.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(st.PersonID) != null);
            Debug.Assert(SDM.LMS.GetDoc(b.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(a.ID) != null);
            Debug.Assert(b.Quantity == 0);
            Debug.Assert(a.Quantity == 0);
            Debug.Assert(SDM.LMS.GetUserBooks(st.PersonID, 7, "").Count == 1);
        }
Exemple #2
0
        public void Test4()
        {
            SDM.LMS.ClearDB();

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

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

            lb.AddBook("b", "B", "B", 0, "B", "B", 0, true, 1, "");
            DocClass b = new DocClass("b");

            st.CheckOut(b.ID);

            Debug.Assert(SDM.LMS.GetUser(lb.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(ft.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(st.PersonID) != null);
            Debug.Assert(SDM.LMS.GetDoc(b.ID) != null);
            Debug.Assert(b.Quantity == 0);
            Debug.Assert(SDM.LMS.GetUserBooks(st.PersonID, 7, "").Count == 1);
            DataBase.Checkouts checkouts = SDM.LMS.GetCheckout(st.PersonID, b.ID);
            Debug.Assert(checkouts.TimeToBack.Subtract((DateTime)checkouts.DateTaked).TotalDays / 7 == 2);
        }
Exemple #3
0
        public void Test34()
        {
            Test32();

            Librarian lb1 = new Librarian("lb1");
            Librarian lb2 = new Librarian("lb2");
            Librarian lb3 = new Librarian("lb3");

            SDM.CurrentUser = lb2;

            lb2.AddBook("d1", "d1", "d1", 2018, "d1", "d1", 2000, false, 3, "");
            lb2.AddBook("d2", "d2", "d2", 2018, "d2", "d2", 2000, false, 3, "");
            lb2.AddBook("d3", "d3", "d3", 2018, "d3", "d3", 2000, false, 3, "");

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

            lb2.RegisterUser("p1", "p1", "p1", "Via Margutta, 3", "30001", false);
            lb2.RegisterUser("p2", "p2", "p2", "Via Sacra, 13", "30002", false);
            lb2.RegisterUser("p3", "p3", "p3", "Via del Corso, 22", "30003", false);
            lb2.RegisterUser("s", "s", "s", "s", "s", false);
            lb2.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");

            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);
            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(SDM.LMS.GetDoc(d1.ID).Quantity == 3);
            Debug.Assert(SDM.LMS.GetDoc(d2.ID).Quantity == 3);
            Debug.Assert(SDM.LMS.GetDoc(d3.ID).Quantity == 3);
        }
Exemple #4
0
        public void Test33()
        {
            Test32();

            Librarian lb1 = new Librarian("lb1");
            Librarian lb2 = new Librarian("lb2");
            Librarian lb3 = new Librarian("lb3");

            SDM.CurrentUser = lb1;

            lb1.AddBook("d1", "d1", "d1", 2018, "d1", "d1", 2000, false, 3, "");
            lb1.AddBook("d2", "d2", "d2", 2018, "d2", "d2", 2000, false, 3, "");
            lb1.AddBook("d3", "d3", "d3", 2018, "d3", "d3", 2000, false, 3, "");

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

            Debug.Assert(SDM.LMS.GetDoc(d1.ID) == null);
            Debug.Assert(SDM.LMS.GetDoc(d2.ID) == null);
            Debug.Assert(SDM.LMS.GetDoc(d3.ID) == null);
        }
Exemple #5
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);
            bool      isBestseller = IsBestseller.SelectedIndex == 0;

            currentUser.AddBook
            (
                TitleTB.Text,
                AutorsTB.Text,
                PublisherTB.Text,
                Convert.ToInt32(PublishYearTB.Text),
                EditionTB.Text,
                DescriptionTB.Text,
                price,
                isBestseller,
                quantity,
                TagsTB.Text
            );

            _previousPage.UpdateTable();
            Close();
        }
Exemple #6
0
        public void Initial_del_4()
        {
            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);

            SDM.CurrentUser = lb;

            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,
                "Algorithms, Data Structures, Complexity, Computational Theory"
            );
            lb.AddBook
            (
                "Algorithms + Data Structures = Programs",
                "Niklaus Wirth",
                "Prentice Hall PTR",
                1978,
                "First Edition",
                "",
                5000,
                false,
                3,
                "Algorithms, Data Structures, Search Algorithms, Pascal"
            );
            lb.AddBook
            (
                "The Art of Computer Programming",
                "Donald E. Knuth",
                "Addison Wesley Longman Publishing Co., Inc.",
                1997,
                "Third Edition",
                "",
                5000,
                false,
                3,
                "Algorithms, Combinatorial Algorithms, Recursion"
            );
            DocClass d1 = new DocClass("Introduction to Algorithms");
            DocClass d2 = new DocClass("Algorithms + Data Structures = Programs");
            DocClass d3 = new DocClass("The Art of Computer Programming");

            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 == 3);

            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);
        }
Exemple #7
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);
        }
Exemple #8
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);
        }