public void MongoGenericRepository_AddAllFindDelete_ShouldWork() { string databaseName = DatabaseName; var provider = new RealMongoDatabaseProvider(databaseName); var repository = new MongoGenericRepository <Book>(provider); var author = new Author("Patrick", "Rothfuss"); var book = new Book("How Old Holly Came To Be", "978-0-9847136-3-9", author); Console.WriteLine(book); repository.Add(book).Wait(); var books = repository.Find(b => true).Result.ToList(); Assert.IsNotNull(books, "Books should not be null."); Assert.AreEqual(1, books.Count, "Number of books in db should be 1."); var bookFromDb = books.FirstOrDefault(); Assert.IsNotNull(bookFromDb, "First book in db should not be null."); Console.WriteLine(bookFromDb); Console.WriteLine(bookFromDb.Id); Assert.AreEqual(book.Title, bookFromDb.Title, "Title should match."); Assert.AreEqual(book.Isbn, bookFromDb.Isbn, "Isbn should match."); Assert.AreEqual(book.Author.FirstName, bookFromDb.Author.FirstName, "Author.FirstName should match."); Assert.AreEqual(book.Author.LastName, bookFromDb.Author.LastName, "Author.LastName should match."); repository.Delete(bookFromDb).Wait(); var booksAfterDeletion = repository.Query?.ToList(); Assert.IsFalse(booksAfterDeletion?.Count > 0, "Number of books after deletion should be 0."); }
public void Cosmosdb_MongoRepository_Delete_ShouldBeTrue() { _repository.Delete("5a7ab4caad2fdc1bd838d646"); Assert.IsTrue(true); }