Beispiel #1
0
        public void TestReaderSerialization()
        {
            Reader      newReader = new Reader("John", 1302);
            LibraryBook newBook   = new LibraryBook(BookType.Drama, 25);

            newBook.PutToStack();
            newReader.TakeBook(newBook);
            newReader.Serialize("file.txt");
            string res = File.ReadAllText("file.txt");

            Assert.AreEqual("Drama\n25\n", res);
        }
Beispiel #2
0
        public void TestLibraryBookUsing()
        {
            LibraryBook newBook = new LibraryBook(BookType.Comedy, 23);
            int         res1    = newBook.GetFromStack();
            bool        res2    = newBook.isInStack();
            int         res3    = newBook.PutToStack();
            bool        res4    = newBook.isInStack();

            Assert.AreEqual(0, res1);
            Assert.AreEqual(false, res2);
            Assert.AreEqual(1, res3);
            Assert.AreEqual(true, res4);
        }
Beispiel #3
0
        public void TestReaderUsing()
        {
            LibraryBook newBook = new LibraryBook(BookType.Drama, 25);

            newBook.PutToStack();
            Reader newReader = new Reader("John", 1302);
            int    res1      = newReader.TakeBook(newBook);
            int    res2      = newReader.TakeBook(newBook);
            int    res3      = newReader.ReturnBook(newBook);
            int    res4      = newReader.ReturnBook(newBook);

            Assert.AreEqual(1, res1);
            Assert.AreEqual(0, res2);
            Assert.AreEqual(1, res3);
            Assert.AreEqual(0, res4);

            LibraryBook newBook2 = new LibraryBook(BookType.Horror, 29);

            newReader[0] = newBook2;
            Assert.AreEqual(newBook2, newReader[0]);
        }