public void DeleteRecordAsync_DeletesNewRecordIfUserAndProjExist() { var context = GetContext(); try { ProjectUserRepository repo = new ProjectUserRepository(context); repo.DeleteRecordAsync("2138b181-4cee-4b85-9f16-18df308f387d", 2).Wait(); Assert.Equal(3, context.ProjectUsers.Count()); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }
public void DeleteRecordAsync_ThrowsExceptionRecordIfItDoesntExists() { var context = GetContext(); try { ProjectUserRepository repo = new ProjectUserRepository(context); ProjectUser rec = new ProjectUser { UserId = "no-user", ProjectId = 1, UserRoleId = AppUserRole.Observer.Id }; Assert.ThrowsAsync <Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException>(async() => await repo.DeleteRecordAsync(rec)).Wait(); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }