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