public async void UpdateAsync_UpdatesInContext() { var venue = VenueGenerator.Create(); using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.Add(venue); context.SaveChanges(); var repository = new VenueRepository(context); var newVenue = await repository.GetByIdAsync(venue.VenueId); newVenue.VenueName = "Old Sports Hall"; await repository.UpdateAsync(newVenue); Assert.Equal(1, await context.Venue.CountAsync()); Assert.Equal(newVenue, await context.Venue.SingleAsync()); } }
public async Task GivenTwoAddressesInDatabase_WhenIUpdate_ItUpdatesTheCorrectAddress() { using (var context = new DefaultContext(DbContextOptions)) { var venueRepository = new VenueRepository(context); var venue1 = GetNewVenue(); var venue2 = GetNewVenue(); venue1 = await venueRepository.CreateAsync(venue1); venue2 = await venueRepository.CreateAsync(venue2); venue2.Name = "test update"; await venueRepository.UpdateAsync(venue2); var updatedVenue = await context.FindAsync <VenueDb>(venue2.Id); Assert.AreEqual(venue2.Name, updatedVenue.Name); Assert.AreEqual(venue2.Email, updatedVenue.Email); Assert.AreEqual(venue2.Phone, updatedVenue.Phone); Assert.AreEqual(venue2.Website, updatedVenue.Website); } }