using System; using Model; namespace TestDataManager; public class DataManagerTest_WithMemberData2 { [Theory] [MemberData(nameof(TestData_WithMemberData2.TestData_BorrowBook), MemberType = typeof(TestData_WithMemberData2))] public async void TestBorrowBook(bool expectedResult, Book bookToBorrow, Person borrower, IDataManager dataManager) { bool result = await dataManager.BorrowBook(bookToBorrow, borrower); Book? book = (await dataManager.GetBooksByIsbn(bookToBorrow?.Isbn, 0, 100)).SingleOrDefault(); Person? person = (await dataManager.GetPersonsByName(borrower?.LastName, 0, 100)).SingleOrDefault(); Assert.Equal(expectedResult, result); if(result) { Assert.NotNull(book); Assert.NotNull(person); Assert.Contains(book, person.Books); Assert.Equal(person, book.Borrower); } else { if(person != null && book != null) { Assert.DoesNotContain(book, person.Books); Assert.NotEqual(person, book.Borrower); } } } }