コード例 #1
0
        public void Get_IndexMoreOrEqualCount_ReturnNull()
        {
            BookRegister register = new BookRegister();

            register.Add(new Book("name", "author", "category", "language", "1999", "123"));
            register.Get(1).Should().Be(null);
        }
コード例 #2
0
        public void Get_RegisterDoesNotContainBookWithCertainIsbn_ReturnNull()
        {
            BookRegister register = new BookRegister();

            register.Add(new Book("name", "author", "category", "language", "1999", "123"));
            register.Get("1").Should().Be(null);
        }
コード例 #3
0
        public void Get_IndexLessThanZero_ReturnNull()
        {
            BookRegister register = new BookRegister();

            register.Add(new Book("name", "author", "category", "language", "1999", "123"));
            register.Get(-1).Should().Be(null);
        }
コード例 #4
0
        public void Get_RegisterContainsBookWithCertainIsbn_ExpectedIsEqualActual()
        {
            BookRegister register = new BookRegister();
            Book         expected = new Book("name", "author", "category", "language", "1999", "123");

            register.Add(expected);
            Book actual = register.Get("123");

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void Get_IndexMoreOrEqualZeroAndLessThanCount_ExpectedIsEqualActual()
        {
            BookRegister register = new BookRegister();
            Book         expected = new Book("name", "author", "category", "language", "1999", "123");

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

            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void Add_AddBookToRegister_AddedBookShouldBeEqualToGiven()
        {
            Book         expected = new Book("name", "author", "category", "language", "1999", "123");
            BookRegister register = new BookRegister();

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

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
        public void FilterBooks_FilterByOnlyByName_ActualShoulBeEqualExpected()
        {
            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);
            TakenBookRegister takenBooks = new TakenBookRegister();
            BookRegister      filtered   = register.FilterBooks("", "", "", "", "n", "", takenBooks);
            Book actual = filtered.Get("789");

            Assert.AreEqual(expected, actual);
        }
コード例 #8
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);
        }
コード例 #9
0
        public void FilterBooks_FilterByOnlyByAvailabiltyTaken_ActualShoulBeEqualExpected()
        {
            ReaderRegister readerRegister = new ReaderRegister();
            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);
            TakenBookRegister takenBooks = new TakenBookRegister();
            bool successful;

            TaskUtils.TakeBook(register, takenBooks, readerRegister, "789", "reader", Convert.ToDateTime("2021-05-12"), out successful, 3);
            BookRegister filtered = register.FilterBooks("", "", "", "", "", "false", takenBooks);
            Book         actual   = filtered.Get("789");

            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
        public void Get_IsbnAndEmptyRegister_ReturnNull()
        {
            BookRegister register = new BookRegister();

            register.Get("123").Should().Be(null);
        }
コード例 #11
0
        public void Get_IndexIsZeroAndEmptyRegister_ReturnNull()
        {
            BookRegister register = new BookRegister();

            register.Get(0).Should().Be(null);
        }