Beispiel #1
0
        public static void Main(string[] args)
        {
            string _fileSource = @"D:\Test\BookStorage.txt";

            if (File.Exists(_fileSource))
            {
                File.Delete(_fileSource);
            }

            IBookListService <Book> _bookService = new BookListService(new BookListStorage(_fileSource));

            _bookService.AddBook(new ScientificBook("978-0735667457", "Richter", "CLR via C#", "O'REILlY", 2013, 896, 176));
            _bookService.AddBook(new ScientificBook("978-5-84592087-4", "Albahary", "C# in nutshell", "O'REILlY", 2017, 1040, 250));
            _bookService.AddBook(new ScientificBook("0-321-12742-0", "Fauler", "Architecture of corporate software applications", "Williams", 2006, 541, 90));
            _bookService.AddBook(new ScientificBook("978-1509304066", "Chambers", "ASP .Net Core application development", "Microsot Press", 2017, 464, 70));

            BookLogger.Debug("Tests");

            var books = _bookService.GetAllBooks();

            PrintArray(books);

            _bookService.AddBook(new ScientificBook("1111111", "Test", "Test", "Test", 2013, 896, 176));
            books = _bookService.GetAllBooks();
            PrintArray(books);

            books = _bookService.SortBookByTag(new YearComparer());
            PrintArray(books);

            _bookService.RemoveBook(new ScientificBook("1111111", "Test", "Test", "Test", 2013, 896, 176));
            books = _bookService.SortBookByTag(new YearComparer());
            PrintArray(books);

            Console.ReadLine();
        }
        /// <summary>
        /// Initialize a new instance of <see cref="BookListService"/>
        /// </summary>
        /// <param name="bookRepository">Books storage</param>
        public BookListService(IBookRepository bookRepository)
        {
            if (bookRepository == null)
            {
                BookLogger.Fatal($"{nameof(bookRepository)} is null value");
                throw new ArgumentNullException(nameof(bookRepository));
            }

            this._bookRepository = bookRepository;
            BookLogger.Debug($"{nameof(BookListService)} was created");
        }
Beispiel #3
0
        public BookListServiceTests()
        {
            if (File.Exists(this._fileSource))
            {
                File.Delete(this._fileSource);
            }

            this._bookService = new BookListService(new BookListStorage(this._fileSource));
            _bookService.AddBook(new ScientificBook("978-0735667457", "Richter", "CLR via C#", "O'REILlY", 2013, 896, 176));
            _bookService.AddBook(new ScientificBook("978-5-84592087-4", "Albahary", "C# in nutshell", "O'REILlY", 2017, 1040, 250));
            _bookService.AddBook(new ScientificBook("0-321-12742-0", "Fauler", "Architecture of corporate software applications", "Williams", 2006, 541, 90));
            _bookService.AddBook(new ScientificBook("978-1509304066", "Chambers", "ASP .Net Core application development", "Microsot Press", 2017, 464, 70));

            BookLogger.Debug("Tests");
        }
        /// <summary>
        /// Gets instance of books storage
        /// </summary>
        /// <param name="fileStorage">Source file name</param>
        public BookListStorage(string fileStorage)
        {
            if (string.IsNullOrWhiteSpace(fileStorage))
            {
                throw new ArgumentNullException($"{nameof(fileStorage)}");
            }

            this._fileStorage = fileStorage;
            this._listBooks   = this.Load();
            if (_listBooks == null)
            {
                BookLogger.Fatal($"{nameof(BookListStorage)} wasn't created");
                throw new ArgumentNullException(nameof(_listBooks));
            }

            BookLogger.Debug($"{nameof(BookListStorage)} was created");
        }
Beispiel #5
0
 public void ClearTest()
 {
     BookLogger.Debug("Test done");
 }
Beispiel #6
0
 public void InitialisationsTestMethod()
 {
     BookLogger.Debug("Test run");
 }