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