public void Patrons_AddCopies_AddsCopiesToPatron()
        {
            Patrons newPatron = new Patrons("Jenny", 1);

            newPatron.Save();

            Books newBooks = new Books("Of Mice and Men", 1);

            newBooks.Save();

            Copies newCopies1 = new Copies(1, DateTime.Now, 1);

            newCopies1.Save();
            Copies newCopies2 = new Copies(1, DateTime.Now, 1);

            newCopies2.Save();

            newCopies1.AddPatrons(newPatron);
            newCopies2.AddPatrons(newPatron);

            List <Patrons> testList    = newCopies1.GetPatronCopies();
            List <Patrons> controlList = new List <Patrons> {
                newPatron
            };

            Assert.Equal(controlList, testList);
        }
Esempio n. 2
0
        public void Copies_AddBook_AddCopiesToPatrons()
        {
            Copies newCopies = new Copies(1, DateTime.Now, 1);

            newCopies.Save();
            Books newBook = new Books("Of mice and men", 1);

            newBook.Save();

            Patrons newPatrons1 = new Patrons("Jerry");

            newPatrons1.Save();
            Patrons newPatrons2 = new Patrons("Jerry");

            newPatrons2.Save();

            newCopies.AddPatrons(newPatrons1);
            newCopies.AddPatrons(newPatrons2);

            List <Patrons> testList    = newCopies.GetPatronCopies();
            List <Patrons> controlList = new List <Patrons> {
                newPatrons1, newPatrons2
            };

            Assert.Equal(controlList, testList);
        }
Esempio n. 3
0
        public void Copies_AddBook_AddCopiesToPatrons()
        {
            Copies newCopies = new Copies(1);

            newCopies.Save();
            Books newBook = new Books("Of mice and men", "John Steinbeck", new DateTime(2017, 05, 06), 1);

            newBook.Save();

            Patrons newPatrons1 = new Patrons("Jerry", 1);

            newPatrons1.Save();
            Patrons newPatrons2 = new Patrons("Jerry", 2);

            newPatrons2.Save();

            // Console.WriteLine(newCopies.GetId());
            // Console.WriteLine(testCopies.GetId());

            newCopies.AddPatrons(newPatrons1);
            newCopies.AddPatrons(newPatrons2);


            List <Patrons> testList    = newCopies.GetPatronCopies();
            List <Patrons> controlList = new List <Patrons> {
                newPatrons1, newPatrons2
            };

            Assert.Equal(controlList, testList);
        }
Esempio n. 4
0
        public void Patrons_Find_FindsPatronsInDB()
        {
            Patrons controlPatrons = new Patrons("Jenny");

            controlPatrons.Save();

            Patrons testPatrons = Patrons.Find(controlPatrons.GetId());

            Assert.Equal(controlPatrons, testPatrons);
        }
Esempio n. 5
0
        public void Patrons_Save_SaveToDatabase()
        {
            Patrons newPatrons = new Patrons("Jenny");

            newPatrons.Save();

            Patrons testPatrons = Patrons.GetAll()[0];

            Assert.Equal(newPatrons, testPatrons);
        }
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/"] = _ => {
         Patrons newPatron = new Patrons(Request.Form["new-user"]);
         newPatron.Save();
         return(View["index.cshtml"]);
     };
     Post["/catalog"] = _ => {
         Dictionary <string, object> newDictionary = new Dictionary <string, object>();
         List <Books> allBooks = Books.GetAll();
         // Patrons test = Patrons.login("Hunter");
         Patrons newPatrons = Patrons.login(Request.Form["user-name"]);
         newDictionary.Add("allBooks", allBooks);
         newDictionary.Add("user", newPatrons);
         // Have a user error message on other page if user incorrectly entered a name
         return(View["catalog.cshtml", newDictionary]);
     };
 }
Esempio n. 7
0
        public void Copies_Delete_DeleteSingleCopy()
        {
            Patrons newPatrons = new Patrons("David", 1);

            newPatrons.Save();
            Books newBook = new Books("Of mice and men", 1);

            newBook.Save();
            Copies newCopies = new Copies(1, DateTime.Now, 1);

            newCopies.Save();

            newCopies.AddPatrons(newPatrons);

            newCopies.Delete();

            List <Copies> testCopies    = Copies.GetAll();
            List <Copies> controlCopies = new List <Copies> {
            };

            Assert.Equal(controlCopies, testCopies);
        }