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