-
-
Notifications
You must be signed in to change notification settings - Fork 821
Open
Description
When I add a Try Catch block to my method that is calling the mocked object I get nothing in return
But removing the Try Catch block makes the mock return the correct List
`
//Mock Setup
var list = ClearanceDataHelpers.GetFullUnsuccessfulList();
var unitOfWork = new Mock<IUnitOfWorkApp>();
var repoMock = new Mock<IRepositoryViewAsync<ClearanceList>>();
repoMock.Setup(r => r.GetListAsync(x => x.VisitorId == It.IsAny<int>())).ReturnsAsync(list);
unitOfWork.Setup(x => x.ClearanceListRepo).Returns(repoMock.Object);
return unitOfWork;
`
Unit Test Part
var dataService = new DataService(_logger.Object, _cache.Object, unitOfWork.Object); var clearance = dataService.GetLatestClearanceByVisitorAsync(1, 1).Result;
Service Method GetLatestClearanceByVisitorAsync - Fails
try { var list = await _unitOfWork.ClearanceListRepo.GetListAsync(x => x.VisitorId == visitorId); } catch (Exception ex) { }
Service Method GetLatestClearanceByVisitorAsync - Works with no Try Catch Block
var list = await _unitOfWork.ClearanceListRepo.GetListAsync(x => x.VisitorId == visitorId);
Metadata
Metadata
Assignees
Labels
No labels
