public async void Add() { using (var context = new BookCollectionContext(ContextOptions)) { IBookService BookService = new BookService(context); Book newBook = new Book { Title = "Title1", Author = "AuthorA", Description = "Some description" }; Book addedBook = await BookService.Add(newBook); context.Books.Remove(addedBook); await context.SaveChangesAsync(); Assert.True(addedBook.Id > 0); } }
public async void Delete() { using (var context = new BookCollectionContext(ContextOptions)) { IBookService BookService = new BookService(context); Book newBook = new Book { Title = "Title3", Author = "AuthorC", Description = "Some description" }; context.Books.Add(newBook); await context.SaveChangesAsync(); var deletedBook = await BookService.Delete(newBook.Id); Assert.Equal(deletedBook.Id, newBook.Id); Assert.False(context.Books.Any(book => book.Id == deletedBook.Id)); } }