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