Skip to content

Commit

Permalink
#10 - removed workaround for older Moq versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Stärk committed Mar 6, 2022
1 parent 5df72e3 commit dda8e2f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Tests.AutoRegistration/AutoRegistrationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@ public void SetUp()
_containerMock = new Mock<IUnityContainer>();
_registered = new List<RegisterEvent>();
var setup = _containerMock
.Setup(c => c.RegisterType(It.IsAny<Type>(), It.IsAny<Type>(), It.IsAny<string>(), It.IsAny<ITypeLifetimeManager>()));
var callback = new RegistrationCallback((from, to, name, lifetime, ips) =>
.Setup(c => c.RegisterType(It.IsAny<Type>(), It.IsAny<Type>(), It.IsAny<string>(), It.IsAny<ITypeLifetimeManager>()))
.Callback<Type, Type, string, ITypeLifetimeManager, InjectionMember[]>((from, to, name, lifetime, ips) =>
{
_registered.Add(new RegisterEvent(from, to, name, lifetime));
_realContainer.RegisterType(from, to, name, lifetime);
});

// Using reflection, because current version of Moq doesn't support callbacks with more than 4 arguments
setup
.GetType()
.GetMethod("SetCallbackWithArguments", BindingFlags.NonPublic | BindingFlags.Instance)
.Invoke(setup, new object[] {callback});

_container = _containerMock.Object;
}
Expand Down

0 comments on commit dda8e2f

Please sign in to comment.