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