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