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

MoqRegistrationSource bug #93

Closed
TheTribe opened this issue Aug 16, 2013 · 0 comments
Closed

MoqRegistrationSource bug #93

TheTribe opened this issue Aug 16, 2013 · 0 comments
Assignees
Labels
Milestone

Comments

@TheTribe
Copy link
Contributor

It seems that Autofac's IRegistrationSource's RegistrationsFor method should really be called AdditionalRegistrationsFor, because the intention is to have the source return an empty set where registrations should be left as-is, and only return additional registrations where appropriate. This was a bit misleading at first glance, and MoqRegistrationSource consequently doubles the registrations for all components resolved via the container. The lines that currently read:

IComponentRegistration[] existingRegistrations = registrationAccessor(service).ToArray();
if (existingRegistrations.Length > 0) return existingRegistrations;

should be changed to read:

IComponentRegistration[] existingRegistrations = registrationAccessor(service).ToArray();
if (existingRegistrations.Length > 0) return Enumerable.Empty<IComponentRegistration>();
@ghost ghost assigned jbatte47 Aug 16, 2013
jbatte47 added a commit to jbatte47/code-patterns that referenced this issue Aug 17, 2013
* extracted ILoggingConfig from LoggingConfig
* switched to interface usage everywhere
* modified LoggingModule logic to allow config source to be unregistered /
  config section to be missing; either case results in a default instance
  of LoggingConfig to be registered
* changed MoqRegistrationSource to only return registrations when creating
  new Mock-based ones; now returns an empty set in al other cases
* added new test assertions to verify the number of registrations before
  and after MoqRegistrationSource is used with a container instance
TheTribe pushed a commit that referenced this issue Aug 21, 2013
This was referenced Aug 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant