Exemple #1
0
        public void GetOverdue_Patron_AllDatesAndBookTitles()
        {
            Patron newPatron = new Patron("Britton");

            newPatron.Save();

            Book newBook1 = new Book("the book");

            newBook1.Save();
            Book newBook2 = new Book("the book2");

            newBook2.Save();

            Copy newCopy1 = new Copy(newBook1.GetId(), 15);

            newCopy1.Save();
            Copy newCopy2 = new Copy(newBook2.GetId(), 15);

            newCopy2.Save();

            newPatron.AddCopy(newCopy1);
            newPatron.AddCopy(newCopy2);

            List <string> expected = new List <string> {
            };
            List <string> dueDates = newPatron.GetOverdue();

            Assert.Equal(expected, dueDates);
        }
Exemple #2
0
        public void GetCheckedOutCopies_ReturnListOfCopies()
        {
            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            Book newBook = new Book("Gone With the Wind");

            newBook.Save();

            Copy newCopy = new Copy(newBook.GetId());

            newCopy.Save();


            DateTime dueDate = new DateTime(2017, 6, 1);

            newPatron.Checkout(newCopy.GetId(), newPatron.GetId(), dueDate);

            DateTime    currentDate    = new DateTime(2017, 7, 1);
            List <Copy> expectedResult = new List <Copy> {
                newCopy
            };
            List <Copy> actualResult = newPatron.GetCheckedOutCopies(currentDate);



            Assert.Equal(expectedResult, actualResult);
        }
Exemple #3
0
        public void GetAvailableCopy_Book_BookAvailableCopies()
        {
            Book testBook1 = new Book("Alice in Wonderland");

            testBook1.Save();

            Copy newCopy1 = new Copy(testBook1.GetId(), 15);

            newCopy1.Save();
            Copy newCopy2 = new Copy(testBook1.GetId(), 12);

            newCopy2.Save();

            Patron testPatron = new Patron("Britton");

            testPatron.Save();
            testPatron.AddCopy(newCopy1);

            List <Copy> availableCopies = testBook1.GetAvailableCopy();
            // int result = availableCopies[0].GetBookId();
            List <Copy> expectedList = new List <Copy> {
                newCopy2
            };

            // int expected = expectedList[0].GetBookId();

            Assert.Equal(expectedList, availableCopies);
        }
Exemple #4
0
        public void GetCheckedOutCopies_OnlyReturnsCheckedoutBook()
        {
            DateTime dueDate = new DateTime(2017, 6, 1);

            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            Book newBook = new Book("Gone With the Wind");

            newBook.Save();

            Copy copy1 = new Copy(newBook.GetId());

            copy1.Save();
            newPatron.Checkout(copy1.GetId(), newPatron.GetId(), dueDate);

            Copy copy2 = new Copy(newBook.GetId());

            copy2.Save();
            Checkout newCheckout = newPatron.Checkout(copy2.GetId(), newPatron.GetId(), dueDate);

            newCheckout.CheckIn();


            DateTime    currentDate    = new DateTime(2017, 7, 1);
            List <Copy> expectedResult = new List <Copy> {
                copy1
            };
            List <Copy> actualResult = newPatron.GetCheckedOutCopies(currentDate);

            Assert.Equal(expectedResult, actualResult);
        }
Exemple #5
0
        public void Patron_ReturnCheckoutItems()
        {
            Patron newPatron = new Patron("Johnny English", "555-555-5555");

            newPatron.Save();

            Author newAuthor = new Author("Ernest Hemingway");

            newAuthor.Save();
            Book newBook = new Book("Old Man and the Sea", 5);

            newBook.Save();
            Book otherBook = new Book("Farewell to Arms", 7);

            otherBook.Save();

            Checkout newCheckout = new Checkout("2017/03/30", newPatron.GetId(), newBook.GetId());

            newCheckout.Save(newBook);
            Checkout otherCheckout = new Checkout("2017/01/30", newPatron.GetId(), otherBook.GetId());

            otherCheckout.Save(newBook);

            List <Checkout> actual   = newPatron.GetCheckouts();
            List <Checkout> expected = new List <Checkout> {
                otherCheckout, newCheckout
            };

            Assert.Equal(expected, actual);
        }
Exemple #6
0
        public void T5_Find_FindsPatronInDatabase()
        {
            Patron testPatron = new Patron("Judy");
              testPatron.Save();

              Patron foundPatron = Patron.Find(testPatron.GetId());

              Assert.Equal(testPatron, foundPatron);
        }
        public void Test_Find_FindPatronInDatabase()
        {
            Patron testPatron1 = new Patron ("Jane", "Doe", "555-555-5555");
              testPatron1.Save();

              Patron result = Patron.Find(testPatron1.GetId());

              Assert.Equal(testPatron1, result);
        }
Exemple #8
0
        public void T3_Save_SavesToDB()
        {
            Patron testPatron = new Patron("Judy");
              testPatron.Save();

              List<Patron> result = Patron.GetAll();
              List<Patron> testList = new List<Patron>{testPatron};

              Assert.Equal(testList, result);
        }
Exemple #9
0
        public void T5_Find_FindsPatronInDatabase()
        {
            Patron testPatron = new Patron("Judy");

            testPatron.Save();

            Patron foundPatron = Patron.Find(testPatron.GetId());

            Assert.Equal(testPatron, foundPatron);
        }
Exemple #10
0
        public void Patron_Find_3()
        {
            Patron newPatron = new Patron("Johnny English", "555-555-5555");

            newPatron.Save();

            Patron foundPatron = Patron.Find(newPatron.GetId());

            Assert.Equal(newPatron, foundPatron);
        }
Exemple #11
0
        public void Patron_Delete_RemoveFromDatabase_4()
        {
            Patron newPatron = new Patron("Johnny English", "555-555-5555");

            newPatron.Save();

            Patron.Delete(newPatron.GetId());

            Assert.Equal(0, Patron.GetAll().Count);
        }
Exemple #12
0
        public void FindById_ReturnsPatronWhenSearchedById()
        {
            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            Patron result = Patron.FindById(newPatron.GetId());

            Assert.Equal(newPatron, result);
        }
Exemple #13
0
        public void T4_Save_AssignsIdToPatron()
        {
            Patron testPatron = new Patron("Judy");
              testPatron.Save();

              Patron savedPatron = Patron.GetAll()[0];
              int result = savedPatron.GetId();
              int testId = testPatron.GetId();

              Assert.Equal(testId, result);
        }
Exemple #14
0
        public void T4_Save_AssignsIdToPatron()
        {
            Patron testPatron = new Patron("Judy");

            testPatron.Save();

            Patron savedPatron = Patron.GetAll()[0];
            int    result      = savedPatron.GetId();
            int    testId      = testPatron.GetId();

            Assert.Equal(testId, result);
        }
Exemple #15
0
        public void Test_Checkout()
        {
            Copy newcopy = new Copy(0, new DateTime(2016,07,20), 1);
              newcopy.Save();

              Patron p = new Patron(0, "Pat", "");
              p.Save();

              p.Checkout(newcopy.id);

              Assert.Equal(p.id, Copy.Find(newcopy.id).patron_id);
        }
Exemple #16
0
        public void T3_Save_SavesToDB()
        {
            Patron testPatron = new Patron("Judy");

            testPatron.Save();

            List <Patron> result   = Patron.GetAll();
            List <Patron> testList = new List <Patron> {
                testPatron
            };

            Assert.Equal(testList, result);
        }
Exemple #17
0
        public void Find_FindsPatronInDatabase_true()
        {
            //Arrange
            Patron testPatron = new Patron("Penny Flowers");

            testPatron.Save();

            //Act
            Patron foundPatron = Patron.Find(testPatron.GetId());

            //Assert
            Assert.Equal(testPatron, foundPatron);
        }
Exemple #18
0
        public void Save_SavesPatronToDatabase_2()
        {
            Patron newPatron = new Patron("Johnny English", "555-555-5555");

            newPatron.Save();

            List <Patron> expectedList = new List <Patron> {
                newPatron
            };
            List <Patron> actualList = Patron.GetAll();

            Assert.Equal(expectedList, actualList);
        }
        public void Test_AddCopy_AddAnCopyToAPatron()
        {
            Patron testPatron = new Patron ("Jane", "Doe", "555-555-5555");
              testPatron.Save();
              Copy newCopy = new Copy ("New", 1, new DateTime(2016, 7, 25), new DateTime(2016, 8, 25));
              newCopy.Save();
              testPatron.AddCopy(newCopy);

              List<Copy> testCopy = new List<Copy> {newCopy};
              List<Copy> allCopies = testPatron.GetCopies();

              Assert.Equal(testCopy, allCopies);
        }
Exemple #20
0
        public void Update_UpdateNameAndPhone_UpdatedInfo()
        {
            Patron newPatron = new Patron("Johnny English", "555-555-5555");

            newPatron.Save();
            string updatedName  = "Billy English";
            string updatedPhone = "555-444-5555";

            newPatron.Update(updatedName, updatedPhone);

            Assert.Equal(updatedName, Patron.GetAll()[0].GetName());
            Assert.Equal(updatedPhone, Patron.GetAll()[0].GetPhone());
        }
Exemple #21
0
        public void Test_Checkin()
        {
            Copy newcopy = new Copy(0, new DateTime(2016,06,27), 1);
              newcopy.Save();

              Patron p = new Patron(0, "Pat", "");
              p.Save();

              p.Checkout(newcopy.id);
              newcopy.Update(new List<string> {"due_date"}, new List<object> {new DateTime(2016,07,19)});
              Copy.Find(newcopy.id).Checkin();

              Assert.Equal(10, Patron.Find(p.id).balance);
        }
Exemple #22
0
        public void Update_UpdatesPatronName_Name()
        {
            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            string newPatronName = "John";

            newPatron.Update(newPatronName);

            string actual = newPatron.GetName();

            Assert.Equal(newPatronName, actual);
        }
Exemple #23
0
        public void Delete_DeletesPatronFromDatabase()
        {
            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            newPatron.Delete();

            List <Patron> expectedResult = new List <Patron> {
            };
            List <Patron> actualResult   = Patron.GetAll();

            Assert.Equal(expectedResult, actualResult);
        }
Exemple #24
0
        public void Save_SavesNewPatron()
        {
            Patron newPatron = new Patron("Joe");

            newPatron.Save();

            List <Patron> expectedResult = new List <Patron> {
                newPatron
            };
            List <Patron> actual = Patron.GetAll();


            Assert.Equal(expectedResult, actual);
        }
Exemple #25
0
        public void T6_Update_UpdatesPatronInDB()
        {
            Patron testPatron = new Patron("Judy");

            testPatron.Save();

            string newName = "Barb";

            testPatron.Update(newName);

            string resultName = testPatron.GetName();

            Assert.Equal(newName, resultName);
        }
Exemple #26
0
        public void GetAll_true()
        {
            //Arrange
            Patron patronOne = new Patron("James McGee");

            patronOne.Save();
            Patron patronTwo = new Patron("Penny Flowers");

            patronTwo.Save();
            // Act
            int result = Patron.GetAll().Count;

            //Assert
            Assert.Equal(2, result);
        }
Exemple #27
0
        public void UpdateName_OnePatron_NewName()
        {
            Patron patron1 = new Patron("Barcelona");

            patron1.Save();
            Patron patron2 = new Patron("Honolulu");

            patron2.Save();

            patron1.UpdateName("ex patron");

            string newName = patron1.GetName();

            Assert.Equal(newName, "ex patron");
        }
        public void Test_DeleteOne_DeletesOnePatron()
        {
            Patron newPatron1 = new Patron ("Jane", "Doe", "555-555-5555");
              Patron newPatron2 = new Patron ("John", "Watson", "444-444-4444");
              newPatron1.Save();
              newPatron2.Save();
              List<Patron> newList = Patron.GetAll();

              newPatron1.DeleteOne();

              List<Patron> resultList = Patron.GetAll();
              List<Patron> testList = new List<Patron> {newPatron2};

              Assert.Equal(testList, resultList);
        }
Exemple #29
0
        public void Save_SavesToDatabase_true()
        {
            //Arrange
            Patron testPatron = new Patron("Penny Flowers");

            testPatron.Save();
            //Act

            List <Patron> result   = Patron.GetAll();
            List <Patron> testList = new List <Patron> {
                testPatron
            };

            //Assert
            Assert.Equal(testList, result);
        }
Exemple #30
0
        public void AddPatron_AddsPatronToCopy_True()
        {
            Patron testPatron = new Patron("Penny Flowers");

            testPatron.Save();
            Copy newCopy = new Copy(1, 5, DateTime.Today);

            newCopy.Save();
            newCopy.AddPatron(testPatron);
            List <Patron> expected = new List <Patron> {
                testPatron
            };
            List <Patron> result = newCopy.GetPatrons();

            Assert.Equal(expected, result);
        }
Exemple #31
0
        public void Test_Save_AssignsIdToPatronObject()
        {
            //Arrange
            Patron testPatron = new Patron("Britton");

            testPatron.Save();

            //Act
            Patron savedPatron = Patron.GetAll()[0];

            int result = savedPatron.GetId();
            int testId = testPatron.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
Exemple #32
0
        public void AddCopy_AddsCopyToPatron_True()
        {
            Patron testPatron = new Patron("Penny Flowers");

            testPatron.Save();
            Copy newCopy = new Copy(1, 5, DateTime.Today);

            newCopy.Save();
            testPatron.AddCopy(newCopy);
            List <Copy> expected = new List <Copy> {
                newCopy
            };
            List <Copy> result = testPatron.GetCopies();

            Assert.Equal(expected, result);
        }
Exemple #33
0
        public void AddCopy_OneCopy_CopyNotAvailable()
        {
            Patron testPatron = new Patron("Britton");

            testPatron.Save();

            Copy newCopy = new Copy(1, 15);

            newCopy.Save();

            testPatron.AddCopy(newCopy);

            int available = newCopy.GetAvailable();

            Assert.Equal(0, available);
        }
Exemple #34
0
        public void Save_SavesCheckoutToDatabase_2()
        {
            Author newAuthor = new Author("Ernest Hemingway");
            newAuthor.Save();
            Book newBook = new Book("Old Man and the Sea", 5);
            newBook.Save();
            newBook.AddAuthor(newAuthor.GetId());
            Patron newPatron = new Patron("Johnny English", "555-555-5555");
            newPatron.Save();

            Checkout newCheckout = new Checkout("2017/05/1", newPatron.GetId(), newBook.GetId());
            newCheckout.Save(newBook);


            Assert.Equal(4, newBook.GetCopies());
        }
Exemple #35
0
        public void Search_PatronTitle_FoundPatronInDatabase()
        {
            //Arrange
            Patron testPatron1 = new Patron("example patron1");

            testPatron1.Save();

            Patron testPatron2 = new Patron("example patron2");

            testPatron2.Save();

            //Act
            Patron result = Patron.Search(testPatron2.GetName());

            //Assert
            Assert.Equal(testPatron2, result);
        }
Exemple #36
0
        public void Test_Find_FindsPatronInDatabase()
        {
            //Arrange
            Patron testPatron1 = new Patron("example patron1");

            testPatron1.Save();

            Patron testPatron2 = new Patron("example patron2");

            testPatron2.Save();

            //Act
            Patron result = Patron.Find(testPatron2.GetId());

            //Assert
            Assert.Equal(testPatron2, result);
        }
Exemple #37
0
        public void T1_Checkout_CreatesACheckoutRecord()
        {
            Patron testPatron = new Patron("Judy");
              testPatron.Save();

              Copy testCopy = new Copy(5);
              testCopy.Save();

              DateTime checkoutDate = new DateTime(2016,08,04);
              DateTime dueDate = new DateTime(2017,01,02);

              Checkout newCheckout = new Checkout(testCopy.GetId(), testPatron.GetId(), checkoutDate, dueDate);
              newCheckout.Save();

              List<Checkout> result = Checkout.GetAll();

              Assert.Equal(newCheckout, result[0]);
        }
Exemple #38
0
        public void CheckIn_OneCopy_PatronAndNewCopy()
        {
            Patron testPatron = new Patron("Britton");

            testPatron.Save();

            Copy newCopy = new Copy(1, 15);

            newCopy.Save();

            testPatron.AddCopy(newCopy);
            testPatron.CheckIn(newCopy);

            List <Copy> allCopies  = testPatron.GetCurrentCopy();
            int         checkedOut = allCopies.Count;

            Assert.Equal(0, checkedOut);
        }
Exemple #39
0
        public void Delete_OnePatron_PatronDeleted()
        {
            Patron testPatron1 = new Patron("Britton");

            testPatron1.Save();
            Patron testPatron2 = new Patron("Megan Britney");

            testPatron2.Save();

            testPatron1.Delete();

            List <Patron> allPatrons = Patron.GetAll();
            List <Patron> expected   = new List <Patron> {
                testPatron2
            };

            Assert.Equal(expected, allPatrons);
        }
        public void Test_Update_UpdatePatronInDatabase()
        {
            Patron newPatron = new Patron ("Jane", "Doe", "555-555-5555");
              newPatron.Save();
              newPatron.SetPhoneNumber ("111-111-1111");
              newPatron.Update();

              Patron updatedPatron = Patron.Find(newPatron.GetId());

              Assert.Equal(newPatron.GetPhoneNumber(), updatedPatron.GetPhoneNumber());
        }
        public void Test_Save_SavesPatronsToDatabase()
        {
            Patron newPatron1 = new Patron ("Jane", "Doe", "555-555-5555");
              Patron newPatron2 = new Patron ("John", "Watson", "444-444-4444");
              newPatron1.Save();
              newPatron2.Save();

              int resultCount = Patron.GetAll().Count;

              Assert.Equal(2, resultCount);
        }
Exemple #42
0
        public void T8_AddCopy_AddsCopyToPatron()
        {
            Book newBook = new Book("Freedom");
              newBook.Save();

              Copy testCopy = new Copy(newBook.GetId());
              testCopy.Save();

              Patron testPatron = new Patron("Barb");
              testPatron.Save();

              testPatron.AddCopy(testCopy);
              List<Copy> result = testPatron.GetCopies();
              List<Copy> testList = new List<Copy> {testCopy};

              Assert.Equal(testList, result);
        }
Exemple #43
0
        public void T9_GetCopys_ReturnsAllPatronCopys()
        {
            Patron testPatron = new Patron("Barb");
              testPatron.Save();

              Copy testCopy1 = new Copy(5);
              testCopy1.Save();

              Copy testCopy2 = new Copy(6);
              testCopy2.Save();

              testPatron.AddCopy(testCopy1);
              List<Copy> result = testPatron.GetCopies();
              List<Copy> testList= new List<Copy>{testCopy1};

              Assert.Equal(testList,result);
        }
Exemple #44
0
        public void T9_GetPatrons_ReturnsAllCopyPatrons()
        {
            Patron testPatron1 = new Patron("Sarah");
              testPatron1.Save();
              Patron testPatron2 = new Patron("John");
              testPatron2.Save();

              Copy testCopy = new Copy(5);
              testCopy.Save();

              testCopy.AddPatron(testPatron1);
              List<Patron> result = testCopy.GetPatron();
              List<Patron> testList= new List<Patron>{testPatron1};

              Assert.Equal(testList,result);
        }
Exemple #45
0
        public void Test_GetHistory()
        {
            Copy newcopy = new Copy(0, new DateTime(2016,07,20), 1);
              newcopy.Save();

              Patron p = new Patron(0, "Pat", "");
              p.Save();

              p.Checkout(newcopy.id);

              Assert.Equal(1, p.GetHistory().Count);
        }
Exemple #46
0
        public HomeModule()
        {
            Get["/"] =_=>{
            return View["index.cshtml"];
              };

              Get["/references"] =_=>{
            List<Book> search = new List<Book> {};
            return View["references.cshtml",search];
              };

              Get["/patrons"]=_=>{
            List<Book> search = new List<Book> {};
            return View["patrons.cshtml",search];
              };

              Get["/books/{id}"] =parameters=> {
            Book b = Book.Find(parameters.id);
            return View["book.cshtml", b];
              };
              Get["/patronview/books/{id}"] =parameters=> {
            Book b = Book.Find(parameters.id);
            return View["patronview-book.cshtml", b];
              };
              Get["/copies/{id}"] =parameters=> {
            Copy c = Copy.Find(parameters.id);
            return View["copy.cshtml", c];
              };
              Get["/patronview/copies/{id}"] =parameters=> {
            Copy c = Copy.Find(parameters.id);
            return View["patronview-copy.cshtml", c];
              };
              Delete["/copies/delete/{id}"] =parameters=> {
            Copy c = Copy.Find(parameters.id);
            c.Delete(new string[] {"checkouts"}, new string[] {"copy_id"});
            return View["book.cshtml", Book.Find(c.book_id)];
              };
              Patch["/books/edit/{id}"] =parameters=> {
            Book b = Book.Find(parameters.id);
            b.Update(new List<string> {"call_number", "collection", "title"}, new List<object> {(string)Request.Form["callNumber"], (string)Request.Form["collection"], (string)Request.Form["title"]});
            b.RemoveAuthors();
            for(int i = 0; i<Request.Form["number-of-authors"]; i++)
            {
              Author a = Author.FindByName(Request.Form["author" + i]);
              if(a==null)
              {
            a = new Author(Request.Form["author" + i]);
            a.Save();
              }
              b.AddAuthor(a.id);
            }
            return View["book.cshtml", b];
              };
              Get["/circulation"] =_=>{
            return View["circulation.cshtml"];
              };
              Post["/patron/new"] =_=> {
            Patron p = new Patron(0, (string)Request.Form["name"], "");
            p.Save();
            return View["patron.cshtml", p];
              };
              Post["/check-out/{id}"] =parameters=> {
            Patron p = Patron.Find(parameters.id);
            Copy c = Copy.Find((int)Request.Form["itemId"]);
            if(c!=null)
            {
              p.Checkout(c.id);
            }
            return View["patron.cshtml", p];
              };
              Get["/check-in"] =_=> {
            return View["check-in.cshtml"];
              };
              Post["/check-in/new"] =_=> {
            int copyId = (int)Request.Form["id"];
            Copy c = Copy.Find(copyId);
            if(c!=null)
            {
              c.Checkin();
            }
            return View["check-in.cshtml"];
              };
              Get["/check-out"] =_=> {
            return View["check-out.cshtml", ""];
              };
              Post["/patron"] =_=> {
            Patron p = Patron.Find((int)Request.Form["patronId"]);
            if(p==null)
            {
              return View["check-out.cshtml", "No Patron Found"];
            }
            else
            {
              return View["patron.cshtml", p];
            }
              };

              Post["/patronview"] =_=> {
            Patron p = Patron.Find((int)Request.Form["patronId"]);
            if(p==null)
            {
              return View["check-out.cshtml", "No Patron Found"];
            }
            else
            {
              return View["patronview.cshtml", p];
            }
              };

              Get["/catalog"] =_=>{
            return View["catalog.cshtml"];
              };
              Post["books/new"] =_=> {
            Book newBook = new Book(Request.Form["callNumber"], Request.Form["collection"], Request.Form["title"]);
            newBook.Save();
            Copy newCopy = new Copy(newBook.id, new DateTime(1900,1,1), 0);
            newCopy.Save();
            for(int i = 0; i<Request.Form["number-of-authors"]; i++)
            {
              Author a = Author.FindByName(Request.Form["author" + i]);
              if(a==null)
              {
            a = new Author(Request.Form["author" + i]);
            a.Save();
              }
              newBook.AddAuthor(a.id);
            }
            return View["book.cshtml", newBook];
              };
              Post["copies/new"] =_=> {
            int bookId = (int)Request.Form["book_id"];
            Copy newCopy = new Copy(bookId, new DateTime(1900,1,1), 0);
            newCopy.Save();
            return View["copy.cshtml", newCopy];
              };

              Post["/search"] =_=> {
            string search = Request.Form["search"];
            string searchType = Request.Form["searchdef"];

            List<Book> booksearch = Book.Search(search,searchType);

            return View["references.cshtml",booksearch];
              };
              Post["/patronview/search"] =_=> {
            string search = Request.Form["search"];
            string searchType = Request.Form["searchdef"];

            List<Book> booksearch = Book.Search(search,searchType);

            return View["patrons.cshtml",booksearch];
              };
              Get["/patron/edit/{id}"]=parameters=>{
            Patron findpatron = Patron.Find(parameters.id);

            return View["updatepatron.cshtml", findpatron];
              };

              Patch["/patron/edit/{id}"]=parameters=>{
            Patron findpatron = Patron.Find(parameters.id);

            findpatron.Update(new List<string>{"name", "notes"}, new List<object>{(string)Request.Form["patronname"], (string)Request.Form["notes"]});

            return View["patron.cshtml", findpatron];
              };
              Patch["/patron/payfines/{id}"]=parameters=> {
            Patron p = Patron.Find(parameters.id);
            p.PayFines(Request.Form["amount"]);
            return View["patron.cshtml", p];
              };

              Get["/overdue"]=_=>
              {
            List<Copy> overDueBooks = Copy.OverdueBooks();
            return View["overdue.cshtml",overDueBooks];
              };

              Get["/patron/{id}"] = parameters => {
            Patron p = Patron.Find(parameters.id);
            return View["patron.cshtml", p];
              };
        }
Exemple #47
0
        public void Test_overDueBooks()
        {
            Patron p = new Patron(0, "Pat", "");
              p.Save();

              Copy newcopy = new Copy(0, new DateTime(2016,06,27), 1);
              newcopy.Save();

              p.Checkout(newcopy.id);

              newcopy.Update(new List<string> {"due_date"}, new List<object> {new DateTime(2016,07,19)});

              List<Copy> isoverdue = Copy.OverdueBooks();

              Assert.Equal(1, isoverdue.Count);
        }
Exemple #48
0
        public void Test_GetItemsOut()
        {
            Patron p = new Patron(0, "Pat", "");
              p.Save();

              Copy newcopy = new Copy(0, new DateTime(2016,07,20), p.id);
              newcopy.Save();

              Assert.Equal(newcopy.id, p.GetItemsOut()[0].id);
        }
Exemple #49
0
        public void T7_Delete_DeletesPatronFromDB()
        {
            //Always remember to save to DB (Save())
              Patron testPatron1 = new Patron("Judy");
              testPatron1.Save();
              Patron testPatron2 = new Patron("Barb");
              testPatron2.Save();

              testPatron1.Delete();

              List<Patron> result = Patron.GetAll();
              List<Patron> testPatrons = new List<Patron> {testPatron2};

              Assert.Equal(testPatrons, result);
        }
Exemple #50
0
        public void T6_Update_UpdatesPatronInDB()
        {
            Patron testPatron = new Patron("Judy");
              testPatron.Save();

              string newName = "Barb";

              testPatron.Update(newName);

              string resultName = testPatron.GetName();

              Assert.Equal(newName, resultName);
        }
        public void Test_GetAll_RetrieveAllPatrons()
        {
            Patron testPatron1 = new Patron ("Jane", "Doe", "555-555-5555");
              Patron testPatron2 = new Patron ("John", "Watson", "444-444-4444");
              testPatron1.Save();
              testPatron2.Save();

              List<Patron> testList = new List<Patron> {testPatron1, testPatron2};
              List<Patron> result = Patron.GetAll();

              Assert.Equal(testList, result);
        }
Exemple #52
0
        public void T8_Addpatron_AddspatronToCopy()
        {
            Book newBook = new Book("Freedom");
              newBook.Save();

              Patron testPatron = new Patron("Sarah");
              testPatron.Save();

              Copy testCopy = new Copy(1);
              testCopy.Save();

              testCopy.AddPatron(testPatron);
              List<Patron> result = testCopy.GetPatron();
              List<Patron> testList = new List<Patron> {testPatron};

              Assert.Equal(testList, result);
        }