private static void Main(string[] args) { Book bookForTest = new Book("978-0-141-34844-5", "Rebecca Donovan", "reason to breathe", "Pinguin Books", 2012, 531, 8); IFormatProvider formatProvider = new BookFormatter(); Console.WriteLine(String.Format(new BookFormatter(), "{0:all}", bookForTest)); Console.WriteLine(String.Format(new BookFormatter(), "{0:nameauthor}", bookForTest)); Console.WriteLine(String.Format(new BookFormatter(), "{0:nameauthoryearpages}", bookForTest)); Console.WriteLine(String.Format(new BookFormatter(), "{0:isbn}", bookForTest)); Console.WriteLine(String.Format(new BookFormatter(), "{0:price}", bookForTest)); Console.WriteLine(String.Format(new BookFormatter(), "{0}", bookForTest)); //Console.WriteLine(bookForTest.ToString("2", )); //Console.WriteLine(bookForTest.ToString("3", )); //Console.WriteLine(bookForTest.ToString("4", )); //Console.WriteLine(bookForTest.ToString("5", )); //Console.WriteLine(bookForTest.ToString("6", )); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("______________________________________________________________________"); IStorage <Book> storage = new BookListStorage("test.bin"); IService service = new BookListService(storage); ToConsole(service.GetAllBooks()); service.AddBook(new Book("978-3-16-123451-10", "test", "test", "test", 2152, 1264, 1111)); ToConsole(service.GetAllBooks()); ToConsole(service.FindBookByTag(service.GetAllBooks(), "name", "test")); ToConsole(service.SortBooksByTag(service.GetAllBooks(), "author")); Console.ReadLine(); }
static void Main(string[] args) { var service = new BookListService(BookListStorage.Instance); service.Save(); var books = new Book[9]; books[0] = new Book("1234567890121", "Author1", "Title1", "Publisher1", 1, 1, 1); books[1] = new Book("1234567890122", "Author2", "Title2", "Publisher1", 1, 1, 1); books[2] = new Book("1234567890123", "Author3", "Title3", "Publisher2", 1, 1, 1); books[3] = new Book("1234567890124", "Author1", "Title4", "Publisher2", 1, 1, 1); books[4] = new Book("1234567890125", "Author2", "Title5", "Publisher3", 1, 1, 1); books[5] = new Book("1234567890126", "Author3", "Title6", "Publisher3", 1, 1, 1); books[6] = new Book("1234567890127", "Author4", "Title1", "Publisher4", 1, 1, 1); books[7] = new Book("1234567890128", "Author1", "Title2", "Publisher4", 1, 1, 1); books[8] = new Book("1234567890129", "Author5", "Title3", "Publisher4", 1, 1, 1); foreach (var book in books) { service.AddBook(book); } service.Save(); var newService = new BookListService(BookListStorage.Instance); foreach (var item in newService.Load().FindBooksByTag(books[1], Book.Tag.ISBN)) { Console.WriteLine(item.ToString("isbn, author", null)); } Console.WriteLine("----------------------------------------"); foreach (var item in newService.FindBooksByTag(books[1], Book.Tag.Author)) { Console.WriteLine(item.ToString("isbn, author", null)); } Console.WriteLine("----------------------------------------"); for (int i = 0; i < newService.CountOfBooks; i++) { Console.WriteLine(newService[i].ToString("isbn, author, title", null)); } Console.WriteLine("---------------------------------------"); newService.SortBooksByTag(Book.Tag.Author); var bookFormatter = new BookFormatter(); for (int i = 0; i < newService.CountOfBooks; i++) { Console.WriteLine(bookFormatter.Format("full", newService[i], null)); } newService.Save(); foreach (var book in books) { newService.RemoveBook(book); } }
public BookFormatterTests() { formatter = new BookFormatter(); book = new Book("1234567890121", "Author1", "Title1", "Publisher1", 1, 1, 1); }