public async Task GetBuIdAsync_ShouldReturnNoCard() { using (var db = new ATMContext(TestOptions.TestDbContextOptions <ATMContext>())) { // Arrange await db.AddRangeAsync(SampleData.CREDITCARDS); await db.SaveChangesAsync(); CreditCard expectedDbCard = null; int cardId = db.CreditCards.OrderBy(x => x.Id).Last().Id + 1; IRepository <CreditCard> repository = new DbCreditCardRepository(db); // Act var result = await repository.GetByIdAsync(cardId); // Assert Assert.Equal(expectedDbCard, result); } }
public async Task GetBuIdAsync_ShouldReturnACard() { using (var db = new ATMContext(TestOptions.TestDbContextOptions <ATMContext>())) { // Arrange var expectedCard = SampleData.CREDITCARDS.First(); await db.AddRangeAsync(SampleData.CREDITCARDS); await db.SaveChangesAsync(); var expectedDbCard = await db.CreditCards.Where(x => x.Number == expectedCard.Number).FirstAsync(); int cardId = expectedDbCard.Id; IRepository <CreditCard> repository = new DbCreditCardRepository(db); // Act var result = await repository.GetByIdAsync(cardId); // Assert Assert.Equal(expectedDbCard, result); } }