public async void ShouldGetCreditCardByID() { var options = new DbContextOptionsBuilder <SecureXContext.SecureXdbContext>() .UseInMemoryDatabase(databaseName: "testXdb9347293427") .Options; CreditCard CC2; using (var context = new SecureXContext.SecureXdbContext(options)) { var service = new SecureXRepository(context); await service.AddCreditCard(CC1); CC2 = await service.GetCreditCardById(CC1.Id); await service.Save(); } using (var context = new SecureXContext.SecureXdbContext(options)) { CC2.Should().BeEquivalentTo(CC1); } }
public async void ShouldUpdateCreditCard() { var options = new DbContextOptionsBuilder <SecureXContext.SecureXdbContext>() .UseInMemoryDatabase(databaseName: "testXdb41241231") .Options; using (var context = new SecureXContext.SecureXdbContext(options)) { var service = new SecureXRepository(context); await service.AddCreditCard(CC1); await service.Save(); CC1.CreditLimit = 111500m; await service.UpdateCreditCard(CC1); await service.Save(); } using (var context = new SecureXContext.SecureXdbContext(options)) { Assert.Equal(111500m, CC1.CreditLimit); Assert.Equal(30, CC1.Id); } }
public async void ShouldDeleteCreditCard() { var options = new DbContextOptionsBuilder <SecureXContext.SecureXdbContext>() .UseInMemoryDatabase(databaseName: "testXdb12315123") .Options; using (var context = new SecureXContext.SecureXdbContext(options)) { var service = new SecureXRepository(context); await service.AddCreditCard(CC1); await service.Save(); await service.DeleteCreditCard(CC1.Id); await service.Save(); } using (var context = new SecureXContext.SecureXdbContext(options)) { Assert.Equal(0, context.CreditCard.CountAsync().Result); } }
public async void ShouldAddCreditCard() { var options = new DbContextOptionsBuilder <SecureXContext.SecureXdbContext>() .UseInMemoryDatabase(databaseName: "testXdb252352") .Options; using (var context = new SecureXContext.SecureXdbContext(options)) { var service = new SecureXRepository(context); await service.AddCreditCard(CC1); await service.Save(); } using (var context = new SecureXContext.SecureXdbContext(options)) { Assert.NotNull(context.CreditCard.FindAsync(CC1.Id).Result); } }