public async void Get() { Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = SpeciesRepositoryMoc.GetContext(); var repository = new SpeciesRepository(loggerMoc.Object, context); Species entity = new Species(); context.Set <Species>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = SpeciesRepositoryMoc.GetContext(); var repository = new SpeciesRepository(loggerMoc.Object, context); Species entity = new Species(); context.Set <Species>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var modifiedRecord = context.Set <Species>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = SpeciesRepositoryMoc.GetContext(); var repository = new SpeciesRepository(loggerMoc.Object, context); Species entity = new Species(); entity.SetProperties(default(int), "B"); context.Set <Species>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var records = await context.Set <Species>().ToListAsync(); records.Count.Should().Be(2); }