public async Task ShouldCreateEntry() { var mapPoint = new MapPoint("Test Point 1", -43.45554434, -110.04886744); using (var context = _contextFactory.CreateDbContext()) { var mapRepository = new MapPointRepository(context); await mapRepository.AddAsync(mapPoint); await mapRepository.SaveChangesAsync(); Assert.NotEqual(Guid.Empty, mapPoint.Id); } using (var context = _contextFactory.CreateDbContext()) { var mapRepository = new MapPointRepository(context); var fetchedMapPoint = await mapRepository.GetByIdAsync(mapPoint.Id); Assert.Equal(mapPoint.Name, fetchedMapPoint.Name); Assert.Equal(mapPoint.Latitude, fetchedMapPoint.Latitude); Assert.Equal(mapPoint.Longitude, fetchedMapPoint.Longitude); _mapPointId = fetchedMapPoint.Id; } }
public async Task ShouldDeleteEntry() { using (var context = _contextFactory.CreateDbContext()) { var mapRepository = new MapPointRepository(context); await mapRepository.DeleteByAsync(mp => mp.Id.Equals(_mapPointId)); await mapRepository.SaveChangesAsync(); } using (var context = _contextFactory.CreateDbContext()) { var mapRepository = new MapPointRepository(context); var mapPoint = await mapRepository.GetByIdAsync(_mapPointId); Assert.Null(mapPoint); } }