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