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

Remove DependencyResolver #21

Closed
tdekoekkoek opened this issue Aug 19, 2012 · 3 comments
Closed

Remove DependencyResolver #21

tdekoekkoek opened this issue Aug 19, 2012 · 3 comments

Comments

@tdekoekkoek
Copy link

I don't think you should be using DependencyResolver as that is specific to Web.Mvc. Your membership provider should be independent of Mvc. Also the error you give is misleading as it's not actually a service locator that is missing, but rather dependency resolver:

        get
        {
            if (_userService == null)
            {
                _userService = DependencyResolver.Current.GetService<IAccountRepository>();
                if (_userService == null)
                    throw new InvalidOperationException(
                        "You need to assign a locator to the ServiceLocator property and it should be able to lookup IAccountRepository.");
            }
            return _userService;

I'm having a beast of a time unit testing this as the dependencyresolover is always failing for some reason, even if I initialize it in my test setup fixture. I think if you would just assign the service locator, it would be sufficient:

        UnityServiceLocator locator = new UnityServiceLocator(_container);
        ServiceLocator.SetLocatorProvider(() => locator);
@jgauffin
Copy link
Owner

It's a MvcContrib project ;)

@tdekoekkoek
Copy link
Author

Good point. Well maybe the error message could be changed, because it's the dependency resolver that should be set. But my main issue is I wasn't able to get this to work in my unit tests. I kept getting this error even when I set my dependency resolver in the setup. Any ideas?

@jgauffin
Copy link
Owner

Show me the code for the unit test.

On Mon, Aug 20, 2012 at 12:48 PM, Trevor de Koekkoek <
notifications@github.com> wrote:

Good point. Well maybe the error message could be changed, because it's
the dependency resolver that should be set. But my main issue is I wasn't
able to get this to work in my unit tests. I kept getting this error even
when I set my dependency resolver in the setup. Any ideas?


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-7865862.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants