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