Esempio n. 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);
        }
        public void AddBookCopy(string title, string author, string publisher, string isbn)
        {
            var bookDescription = new BookDescription(title, author, publisher);
            var bookCopy        = new BookCopy(bookDescription, DateTime.Now, isbn);

            _dataRepository.AddBookCopy(bookCopy);
        }
        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);
            }
        }