예제 #1
0
        public void Get_RegisterDoesNotContainReaderWithCertainName_ReturnNull()
        {
            ReaderRegister register = new ReaderRegister();

            register.Add(new Reader("name"));
            register.Get("n").Should().Be(null);
        }
예제 #2
0
        public void Get_IndexMoreOrEqualCount_ReturnNull()
        {
            ReaderRegister register = new ReaderRegister();

            register.Add(new Reader("name"));
            register.Get(1).Should().Be(null);
        }
예제 #3
0
        public void Get_IndexLessThanZero_ReturnNull()
        {
            ReaderRegister register = new ReaderRegister();

            register.Add(new Reader("name"));
            register.Get(-1).Should().Be(null);
        }
예제 #4
0
        public void Get_RegisterContainsReaderWithCertainIsbn_ExpectedIsEqualActual()
        {
            ReaderRegister register = new ReaderRegister();
            Reader         expected = new Reader("name");

            register.Add(expected);
            Reader actual = register.Get("name");

            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void Get_IndexMoreOrEqualZeroAndLessThanCount_ExpectedIsEqualActual()
        {
            ReaderRegister register = new ReaderRegister();
            Reader         expected = new Reader("name");

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

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void Add_AddReaderToRegister_AddedReaderShouldBeEqualToGiven()
        {
            Reader         expected = new Reader("name");
            ReaderRegister register = new ReaderRegister();

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

            Assert.AreEqual(expected, actual);
        }
예제 #7
0
        public void ReturnBook_ReturnDateIsNotLate_LateReturnIsFalseAndReaderMinusBookCountAndRemoveBookFfromTakenBookRegister()
        {
            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);
            bool lateReturn;

            TaskUtils.ReturnBook(takenRegister, readerRegister, "123", out lateReturn);
            readerRegister.Get("Name").BookCount.Should().Be(0);
            Assert.IsFalse(lateReturn);
            takenRegister.Get("123").Should().Be(null);
        }
예제 #8
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);
        }
예제 #9
0
        public void Get_NameAndEmptyRegister_ReturnNull()
        {
            ReaderRegister register = new ReaderRegister();

            register.Get("name").Should().Be(null);
        }
예제 #10
0
        public void Get_IndexIsZeroAndEmptyRegister_ReturnNull()
        {
            ReaderRegister register = new ReaderRegister();

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