public async Task DeletingEntitiesByKey_RemoveEntriesWithExisitngKeys() { // Arrange await _db.Database.EnsureDeletedAsync(); await _db.Database.EnsureCreatedAsync(); var targetIds = new[] { Guid.Parse("EFED4F70-8B1A-4BB3-B14B-B6EA2EEE2267"), Guid.Parse("323A3F72-3DAB-422B-A306-8E155CE1F61A"), Guid.Parse("8299D594-0AA4-4D33-8EB2-4557A2221AF8") }; var preMoamraths = _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArray(); Assert.Equal(3, preMoamraths.Length); sut = new MoamrathRepository(_db); // Act await sut.DeleteAsync(targetIds); // Assert var postMoamraths = _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArray(); Assert.Empty(postMoamraths); }
public async Task AttemptingADelete_WithEmptyIds_HasNoEffect() { // Arrange sut = new MoamrathRepository(_db); var preMoamraths = await _db.Moamraths.CountAsync(); // Act await sut.DeleteAsync(); // Assert var postMoamraths = await _db.Moamraths.CountAsync(); Assert.Equal(preMoamraths, postMoamraths); }
public async Task DeletingEntitiesByKey_WillNotAffectNonExistentKeys() { // Arrange await _db.Database.EnsureDeletedAsync(); await _db.Database.EnsureCreatedAsync(); var targetIds = new[] { Guid.Parse("EFED4F70-8B1A-4BB3-B14B-B6EA2EEE2267"), Guid.NewGuid(), Guid.NewGuid() }; var preMoamraths = await _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArrayAsync(); Assert.Single(preMoamraths); sut = new MoamrathRepository(_db); // Act await sut.DeleteAsync(targetIds); // Assert var postMoamraths = await _db.Moamraths.Where(x => targetIds.Contains(x.Id)).ToArrayAsync(); Assert.Empty(postMoamraths); }