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