November Happy Hour will be moved to Thursday December 5th.

Make _approvalDefinitionRepository.GetAsync(ContentReference) unit test friendly

Vote:
 

The interface IApprovalDefinitionRepository has some basic methods I can mock against but if I want to unit test the _approvalDefinitionRepository.GetAsync(ContentReference), that I guess many will use, it's extremely more work to be done to mock.

Before reaching the interface and method  IApprovalDefinitionRepository.GetItemsAsync(IEnumerable()) that is unit test friendly we go through several static classes/methods (at least one is even internal). It's not that easy to unit test.

Please make it more unit test friendly so that instead of looking at Uris in the IApprovalDefinitionRepository.GetItemsAsync(IEnumerable()) I can match against ContentReferences in _approvalDefinitionRepository.GetAsync(ContentReference).

Example

_approvalDefinitionRepository.Setup(x => x.GetItemsAsync(It.IsAny>()))
.ReturnsAsync((IEnumerable inUris) =>
{
if(inUris.ElementAt(0).ToString().EndsWith(myContentReference.Id.ToString()))
{
// Do stuff
}
else
{
// Do stuff
}

return new List { new ContentApprovalDefinition() };
});

would be more easy if I could just do 
_approvalDefinitionRepository.Setup(x => x.GetAsync(myContentReference)).ReturnAsync(...);

#178004
Edited, Apr 26, 2017 15:17
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.