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