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