Example #1
0
        public void Count_GetCount_CountShouldBeEqualToAddedBookCount()
        {
            BookRegister register = new BookRegister();

            register.Add(new Book("name", "author", "category", "language", "1999", "123"));
            register.Add(new Book("n", "a", "c", "l", "1999", "789"));
            register.Count().Should().Be(2);
        }
Example #2
0
        public void BookRegister_CreatedBookRegister_BookRegisterCountShouldBeNull()
        {
            BookRegister register = new BookRegister();
            int          expected = 0;
            int          actual   = register.Count();

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void Remove_GivenBookIsbnNotEqualToOneInRegister_DoesNotRemove()
        {
            BookRegister register = new BookRegister();
            Book         book     = new Book("name", "author", "category", "language", "1999", "123");
            Book         remove   = new Book("n", "a", "c", "l", "1999", "1");

            register.Add(book);
            register.Remove(remove);
            register.Count().Should().Be(1);
        }
Example #4
0
        public void Remove_GivenBookIsbnEqualToOneInRegister_RemovesThatBookFromRegister()
        {
            BookRegister register = new BookRegister();
            Book         book1    = new Book("name", "author", "category", "language", "1999", "123");
            Book         remove   = new Book("n", "a", "c", "l", "1999", "123");

            register.Add(book1);
            register.Remove(remove);
            register.Count().Should().Be(0);
        }
Example #5
0
        public void Remove_GivenBookIsEqualToOneInRegister_RemovesGivenBookFromRegister()
        {
            BookRegister register = new BookRegister();
            Book         book1    = new Book("name", "author", "category", "language", "1999", "123");
            Book         expected = new Book("n", "a", "c", "l", "1999", "789");

            register.Add(book1);
            register.Add(expected);
            register.Remove(book1);
            Book actual = register.Get(0);

            register.Count().Should().Be(1);
            Assert.AreEqual(expected, actual);
        }
Example #6
0
        public void Remove_GivenBookIsbnNotEqualToOneInRegister_DoesNotRemove()
        {
            BookRegister register     = new BookRegister();
            Book         book1        = new Book("name", "author", "category", "language", "1999", "123");
            Book         book2        = new Book("n", "a", "c", "l", "1999", "789");
            Reader       reader1      = new Reader("Name");
            Reader       reader2      = new Reader("N");
            TakenBook    takenBook    = new TakenBook(book1, Convert.ToDateTime("2021-05-12"), reader1);
            TakenBook    bookToRemove = new TakenBook(book2, Convert.ToDateTime("2021-05-12"), reader2);

            register.Add(takenBook);
            register.Remove(bookToRemove);
            register.Count().Should().Be(1);
        }