public async void Get() { Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext(); var repository = new PostHistoryRepository(loggerMoc.Object, context); PostHistory entity = new PostHistory(); context.Set <PostHistory>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext(); var repository = new PostHistoryRepository(loggerMoc.Object, context); PostHistory entity = new PostHistory(); entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B", "B", 1); context.Set <PostHistory>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext(); var repository = new PostHistoryRepository(loggerMoc.Object, context); PostHistory entity = new PostHistory(); context.Set <PostHistory>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var modifiedRecord = context.Set <PostHistory>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }