public void SetUp() { existingBook1 = CreateBook("Introduction To Programming", "John Doe", "2015"); existingBook2 = CreateBook("War and Peace", "Joe Hart", "1995"); existingBook3 = CreateBook("Introduction To C#", "Ari Doe", "2000"); existingBook4 = CreateBook("Cooking Recipes", "John Papa", "1998"); library = CreateLibrary(existingBook1, existingBook2, existingBook3, existingBook4); }
public void Remove(Book book) { if (!Books.Any(b => b.Equals(book))) { throw new InvalidOperationException("Book does not exists in library"); } Books.Remove(book); }
public void Add(Book book) { if(Books.Any(b => b.Equals(book))) { throw new InvalidOperationException("Book already exists in library"); } Books.Add(book); }
private static void AddBook(Library library) { var book = new Book(); Console.Write("Book name: "); book.Name = Console.ReadLine(); Console.Write("Author: "); book.Author = Console.ReadLine(); Console.Write("Published year: "); book.PublishedYear = Console.ReadLine(); try { library.Add(book); } catch (InvalidOperationException ex) { Console.WriteLine("Error. Details: " + ex.Message); } }
public void SetUp() { existingBook = CreateBook("Introduction To Programming", "John Doe", "2015"); library = CreateLibrary(existingBook); }