Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPnPContextFactory >> PnPContext #1570

Open
1 task done
freddieontheweb opened this issue Nov 7, 2024 · 2 comments
Open
1 task done

IPnPContextFactory >> PnPContext #1570

freddieontheweb opened this issue Nov 7, 2024 · 2 comments
Labels
area: framework ⚙ Changes in the SDK core framework code question Further information is requested

Comments

@freddieontheweb
Copy link

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.

@jansenbe
Copy link
Contributor

@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.

@jansenbe jansenbe added question Further information is requested area: framework ⚙ Changes in the SDK core framework code labels Nov 18, 2024
@freddieontheweb
Copy link
Author

freddieontheweb commented Nov 19, 2024

@jansenbe: In August 2022 you committed the changes (32dcbfb). If that method works, I think you should release it, in order to Moq correctly PnPContext. Using IPnPContext approach is ineffective for my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework ⚙ Changes in the SDK core framework code question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants