public async void Create() { Mock <ILogger <CreditCardRepository> > loggerMoc = CreditCardRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = CreditCardRepositoryMoc.GetContext(); var repository = new CreditCardRepository(loggerMoc.Object, context); var entity = new CreditCard(); await repository.Create(entity); var record = await context.Set <CreditCard>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <CreditCardRepository> > loggerMoc = CreditCardRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = CreditCardRepositoryMoc.GetContext(); var repository = new CreditCardRepository(loggerMoc.Object, context); CreditCard entity = new CreditCard(); context.Set <CreditCard>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.CreditCardID); record.Should().NotBeNull(); }
public async void Delete() { Mock <ILogger <CreditCardRepository> > loggerMoc = CreditCardRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = CreditCardRepositoryMoc.GetContext(); var repository = new CreditCardRepository(loggerMoc.Object, context); CreditCard entity = new CreditCard(); context.Set <CreditCard>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.CreditCardID); CreditCard modifiedRecord = await context.Set <CreditCard>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <CreditCardRepository> > loggerMoc = CreditCardRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = CreditCardRepositoryMoc.GetContext(); var repository = new CreditCardRepository(loggerMoc.Object, context); CreditCard entity = new CreditCard(); context.Set <CreditCard>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new CreditCard()); var modifiedRecord = context.Set <CreditCard>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }