public async void GetByIdAsync_ReturnsCorrectItems() { var list = VenueGenerator.CreateList(5); var expected = list[2]; using (var context = new booking_facilitiesContext(contextOptions)) { context.Database.EnsureCreated(); context.Venue.AddRange(list); context.SaveChanges(); Assert.Equal(list.Count, await context.Venue.CountAsync()); var repository = new VenueRepository(context); var venue = await repository.GetByIdAsync(expected.VenueId); Assert.IsType <Venue>(venue); Assert.Equal(expected, venue); } }
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()); } }