public void Map_ReturnsSharedBookListItem_When_SharedBookListItemIsMapped() { var sharedBookListItem = new SharedBookListItem { Id = 54, Book = new Book { Author = "Author", Title = "Title", GenreId = "stories", Genre = new Genre { Id = "stories", Name = "Stories" } }, BookListId = 5 }; var mapped = Mapper.Map <SharedBookListItem, SharedBookListItemDto>(sharedBookListItem); Assert.Equal(sharedBookListItem.Id, mapped.Id); Assert.Equal(sharedBookListItem.Book.Title, mapped.Title); Assert.Equal(sharedBookListItem.Book.Author, mapped.Author); Assert.Equal(sharedBookListItem.BookListId, mapped.ListId); Assert.Equal(sharedBookListItem.Book.Genre.Name, mapped.Genre); }
private static BookListItem CreateItem(BookList list, AddBookToLists command) { BookListItem item; if (list.Type == BookListType.Shared) { item = new SharedBookListItem { BookListId = list.Id, BookId = command.BookId }; } else { item = new PrivateBookListItem { BookId = command.BookId, BookListId = list.Id }; } return(item); }