Пример #1
0
        public void AddTheSameObjectTest()
        {
            Reader reader = new Reader("Dominik", "Karski");

            Assert.AreEqual(repository.GetAllReaders().Count(), 4);
            repository.AddReader(reader);
            Assert.AreNotEqual(repository.GetAllReaders().Count(), 5);

            BookDescription book  = new BookDescription("Metro 2033", "Dmitry Glukhovsky", "Insignis");
            var             count = repository.GetAllBookDescriptions().Count();

            Assert.AreEqual(count, 5);

            repository.AddBookDescription(book);
            repository.AddBookDescription(book);
            repository.AddBookDescription(book);
            Assert.AreEqual(count, 5);

            count = repository.GetAllBookDescriptions().Count();
            Assert.AreNotEqual(count, 6);

            Assert.AreEqual(repository.GetAllBookCopies().Count(), 5);
            repository.AddBookCopy(repository.GetBookCopy(0));
            Assert.AreEqual(repository.GetAllBookCopies().Count(), 5);

            Assert.AreEqual(repository.GetAllBookEvents().Count(), 7);
            repository.AddBookEvent(repository.GetBookEvent(0));
            Assert.AreEqual(repository.GetAllBookEvents().Count(), 7);
        }
Пример #2
0
        public void populate()
        {
            foreach (var bookDescription in _populateData.GetBookDescriptions())
            {
                _dataRepository.AddBookDescription(bookDescription);
            }

            foreach (var bookCopy in _populateData.GetBookCopies())
            {
                _dataRepository.AddBookCopy(bookCopy);
            }

            foreach (var reader in _populateData.GetReaders())
            {
                _dataRepository.AddReader(reader);
            }

            foreach (var bookEvent in _populateData.GetBookEvents())
            {
                _dataRepository.AddBookEvent(bookEvent);
            }
        }
Пример #3
0
        public void RentBook(Reader reader, BookCopy bookCopy)
        {
            var rent = new Rent(bookCopy, reader, DateTime.Now);

            _dataRepository.AddBookEvent(rent);
        }