public void Setup() { ctx.AddTestAuthorization().SetAuthorized("Test") .SetRoles("Medical Practitioner").SetClaims(new Claim(ClaimTypes.Role, "Admin")); var patientRepo = new Mock <IPatientData>(); patientRepo.Setup(x => x.GetAllPatients()).Returns(Task.FromResult(new List <PatientModel> { new PatientModel() { FirstName = "TestFirstName", LastName = "TestLastName", Address = "TestAddress", ContactNumber = "12345678", DateOfBirth = DateTime.UtcNow, Email = "*****@*****.**", Id = 1 } })); var mockLogger = new Mock <ILogger <Patient> >(); ctx.Services.AddSingleton <ILogger <Patient> >(mockLogger.Object); ctx.Services.AddSingleton <IPatientData>(patientRepo.Object); ctx.Services.AddSingleton <NavigationManager>(navigationManager.Object); ctx.Services.AddSingleton <IJSRuntime>(ijsRuntime.Object); }