예제 #1
0
        public void Contains_EmptyRegister_False()
        {
            TakenBookRegister register = new TakenBookRegister();
            bool actual = register.Contains("1");

            Assert.IsFalse(actual);
        }
예제 #2
0
        public void Contains_RegisterDoesNotContainBookWithCertainIsbn_False()
        {
            TakenBookRegister register = new TakenBookRegister();
            Book   book   = new Book("name", "author", "category", "language", "1999", "123");
            Reader reader = new Reader("Name");

            register.Add(new TakenBook(book, Convert.ToDateTime("2021-05-12"), reader));
            bool actual = register.Contains("1");

            Assert.IsFalse(actual);
        }
예제 #3
0
        public void TakeBook_NewReaderTakesBook_SuccessfullTrueAddbookToTakenBookRegisterAndAddsNewReaderToReaderRegister()
        {
            BookRegister libraryRegister = new BookRegister();
            Book         book1           = new Book("name", "author", "category", "language", "1999", "123");

            libraryRegister.Add(book1);
            ReaderRegister    readerRegister = new ReaderRegister();
            TakenBookRegister takenRegister  = new TakenBookRegister();
            bool successful;

            TaskUtils.TakeBook(libraryRegister, takenRegister, readerRegister, "123", "Name", Convert.ToDateTime("2021-05-16"), out successful, 3);
            bool containsTakenRegister  = takenRegister.Contains("123");
            bool containsReaderRegister = readerRegister.Contains("Name");

            Assert.IsTrue(successful);
            Assert.IsTrue(containsTakenRegister);
            Assert.IsTrue(containsReaderRegister);
        }
예제 #4
0
        public void DeleteBook_DeletesBookFromBookRegisterAndTakenBookREgister_BookRegisterAndTakenBookRegisterDoesNotContainBook()
        {
            BookRegister libraryRegister = new BookRegister();
            Book         book1           = new Book("name", "author", "category", "language", "1999", "123");

            libraryRegister.Add(book1);
            ReaderRegister    readerRegister = new ReaderRegister();
            TakenBookRegister takenRegister  = new TakenBookRegister();
            bool successful;

            TaskUtils.TakeBook(libraryRegister, takenRegister, readerRegister, "123", "Name", Convert.ToDateTime("2022-05-16"), out successful, 3);
            TaskUtils.DeleteBook(takenRegister, libraryRegister, readerRegister, "123");
            bool containsBookRegister      = takenRegister.Contains("123");
            bool containsTakenBookRegister = readerRegister.Contains("123");

            Assert.IsFalse(containsBookRegister);
            Assert.IsFalse(containsTakenBookRegister);
        }
예제 #5
0
        public void TakeBook_ReaderHasAlreadyTakenOneBook_SuccessfullTrueAddbookToTakenBookRegisterAndAddPlusOneToReaderBookCount()
        {
            BookRegister libraryRegister = new BookRegister();
            Book         book1           = new Book("name", "author", "category", "language", "1999", "123");
            Book         book2           = new Book("n", "a", "c", "language", "1999", "123456");

            libraryRegister.Add(book1);
            libraryRegister.Add(book2);
            ReaderRegister    readerRegister = new ReaderRegister();
            TakenBookRegister takenRegister  = new TakenBookRegister();
            bool successful;

            TaskUtils.TakeBook(libraryRegister, takenRegister, readerRegister, "123", "Name", Convert.ToDateTime("2021-05-16"), out successful, 3);
            TaskUtils.TakeBook(libraryRegister, takenRegister, readerRegister, "123456", "Name", Convert.ToDateTime("2021-05-16"), out successful, 3);
            bool containsTakenRegister = takenRegister.Contains("123456");

            Assert.IsTrue(successful);
            Assert.IsTrue(containsTakenRegister);
            readerRegister.Get("Name").BookCount.Should().Be(2);
        }