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