public void BookItemTest() { string title1 = "Dziady", author1 = "Adam Mickiewicz"; BookItem tester = new BookItem(title1, author1); BookItem testerCopy = new BookItem(title1, author1); Assert.Contains(title1, tester.ToString()); Assert.True(tester.Equals(testerCopy)); }
public override string ToString() { StringBuilder RetVal = new StringBuilder(); foreach (TBook BookItem in this) { RetVal.AppendLine(string.Format("Book: {0}", BookItem.ToString())); } return(RetVal.ToString()); }
public override string ToString() { StringBuilder RetVal = new StringBuilder(); lock ( _LockItems ) { foreach (TBook BookItem in Items) { RetVal.AppendLine(BookItem.ToString()); } } return(RetVal.ToString()); }
public void UpdateBookItemTest() { DataRepository dataRepository = new DataRepository(); Author author = new Author("George", "Orwell"); Book book = new Book("1984", new List <Author> { author }, "1984-11-123", "Opis książki"); BookItem bookItemBefore = new BookItem(book, DateTime.Today); dataRepository.AddBookItem(bookItemBefore); Assert.AreEqual(String.Format("1984 by George Orwell [{0}] - Opis książki [{1}]", book.IsbnNumber, bookItemBefore.Guid), bookItemBefore.ToString()); Book bookAfter = new Book("1985", new List <Author> { author }, "1984-11-123", "Opis książki"); BookItem bookItemAfter = new BookItem(bookAfter, DateTime.Today); dataRepository.UpdateBookItem(bookItemBefore.Guid, bookItemAfter); BookItem updatedBookItem = dataRepository.GetBookItem(bookItemAfter.Guid); Assert.AreEqual(1, dataRepository.GetAllBookItems().Count); Assert.AreEqual(String.Format("1985 by George Orwell [{0}] - Opis książki [{1}]", book.IsbnNumber, bookItemAfter.Guid), updatedBookItem.ToString()); }