IPnPContextFactory >> PnPContext
Opened this issue · 2 comments
Category
- Bug
Describe the bug
The IPnPContextFactory interface has create methods returning concretions and, as discussed elsewhere, PnPContext only has internal constructors meaning that setting up responses for Create calls is problematic.
Steps to reproduce
For example, the following snippet will fail:
// some code
_contextFactory.Setup(x =>
x.CreateAsync(new Uri(SharepointBaseUri), new WrappedTokenProvider(SharepointToken), null))
.Returns(Task.FromResult(ctx.Object));
// some code
Expected behavior
As PnPContext implements the IPnPContext interface, I would expect the Create method calls on IPnPContextFactory to return abstractions and not concretions thereby allowing for unit testing of code consuming these classes.
@freddieontheweb : I get your point, it's indeed not ideal for testing but it's how things have been designed for this version. We can possibly re-evaluate for a future major version revamp but we've no short-term plans for this at the moment. I'm open for a suggestion from your side that implements what you need without breaking the existing method signatures.