Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
darrencauthon committed Apr 21, 2016
1 parent a08f542 commit e7d3977
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/AutoMoq/Mocking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ public MockCreationResult CreateANewMockObjectAndRegisterIt(Type type)
var result = CreateAMockObjectFor(type);
var mock = (Mock) result.MockObject;

var method = ioc.GetType().GetMethods()[2];
var registerMethod = method.MakeGenericMethod(type);
registerMethod.Invoke(ioc, new[] { mock.Object });
ioc.GetType()
.GetMethods()
.First(x => x.Name == "RegisterInstance" && x.IsGenericMethod)
.MakeGenericMethod(type)
.Invoke(ioc, new[] { mock.Object });

ioc.Resolve<AutoMoqer>().SetMock(type, mock);
return result;
Expand Down

0 comments on commit e7d3977

Please sign in to comment.