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