diff --git a/test/CTS/AssessmentControllerTest.cs b/test/CTS/AssessmentControllerTest.cs index 289fcd92f..c9b412246 100644 --- a/test/CTS/AssessmentControllerTest.cs +++ b/test/CTS/AssessmentControllerTest.cs @@ -263,7 +263,7 @@ private static bool IsForbidResult(ActionResult a) Assert.True(result != null || forbidResult != null); } - catch (Exception) + catch (Xunit.Sdk.XunitException) { return false; } @@ -279,7 +279,7 @@ private static bool IsNotFoundResult(ActionResult a) var result = a.Result as NotFoundResult; Assert.Equal((int)HttpStatusCode.NotFound, result?.StatusCode); } - catch (Exception) + catch (Xunit.Sdk.XunitException) { return false; } diff --git a/test/ClinicalScheduler/EmailNotificationTest.cs b/test/ClinicalScheduler/EmailNotificationTest.cs index be00573e6..508242f0a 100644 --- a/test/ClinicalScheduler/EmailNotificationTest.cs +++ b/test/ClinicalScheduler/EmailNotificationTest.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using NSubstitute; using NSubstitute.ExceptionExtensions; @@ -281,7 +282,7 @@ await _context.Persons.AddAsync(new Models.ClinicalScheduler.Person { result = await _service.RemoveInstructorScheduleAsync(savedSchedule.InstructorScheduleId); } - catch (Exception ex) + catch (Exception ex) when (ex is InvalidOperationException or DbUpdateException or SqlException or OperationCanceledException) { caughtException = ex; System.Console.WriteLine($"Exception caught: {ex.GetType().Name}: {ex.Message}"); @@ -463,7 +464,7 @@ await _context.Persons.AddAsync(new Models.ClinicalScheduler.Person { result = await _service.RemoveInstructorScheduleAsync(savedPrimarySchedule.InstructorScheduleId); } - catch (Exception ex) + catch (Exception ex) when (ex is InvalidOperationException or DbUpdateException or SqlException or OperationCanceledException) { caughtException = ex; System.Console.WriteLine($"Exception caught: {ex.GetType().Name}: {ex.Message}"); diff --git a/test/ClinicalScheduler/RotationServiceTest.cs b/test/ClinicalScheduler/RotationServiceTest.cs index 4c17e1580..905415e8f 100644 --- a/test/ClinicalScheduler/RotationServiceTest.cs +++ b/test/ClinicalScheduler/RotationServiceTest.cs @@ -95,7 +95,7 @@ private void SeedTestData() } _context.SaveChanges(); } - catch (Exception ex) + catch (Exception ex) when (ex is DbUpdateException or InvalidOperationException) { // Log the exception and provide a clear error message for debugging Console.WriteLine($"Error seeding test data: {ex.Message}");