private IStatusRepository GetStatusRepo(string name, string accessInfo, string result) { List <StatusResponse> responseDatas = new List <StatusResponse>(); var responseData = new StatusResponse() { Name = name, AccessInfo = accessInfo, Result = result, NoErrors = true }; responseDatas.Add(responseData); var statusRepoMock = new Mock <IStatusRepository>(); statusRepoMock.Setup(r => r.GetStatuses(It.IsAny <int>())).ReturnsAsync(responseDatas); statusRepoMock.Setup(r => r.Name).Returns(name); statusRepoMock.Setup(r => r.AccessInfo).Returns(accessInfo); return(statusRepoMock.Object); }
/// <summary> /// Modifies serviceStatus in place, returns whether status was successfully obtained. /// </summary> private async Task <List <StatusResponse> > TryGetStatusResponse(IStatusRepository statusRepo) { try { return(await statusRepo.GetStatuses(GET_STATUS_TIMEOUT)); } catch (Exception ex) { await Log.LogError(LogSource, ex); List <StatusResponse> responseWithError = new List <StatusResponse>(); var responseData = new StatusResponse() { Name = statusRepo.Name, AccessInfo = statusRepo.AccessInfo, Result = $"ERROR: {ex.ToString()}", NoErrors = false }; responseWithError.Add(responseData); return(responseWithError); } }