Last active
January 8, 2016 16:07
-
-
Save jameshulse/81771d6b10c9a96927f0 to your computer and use it in GitHub Desktop.
Revisions
-
jameshulse renamed this gist
Jan 8, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ public class TestingWithDependencies : TestKit { public TestingWithDependencies() { var dependencyResolver = new TestDependencyResolver(); -
jameshulse created this gist
Jan 8, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ public class MyTests : TestKit { public MyTests() { var dependencyResolver = new TestDependencyResolver(); dependencyResolver.Register<MyActor>(Props.Create<MyActor>()); Sys.AddDependencyResolver(dependencyResolver); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ public class TestDependencyResolver : IDependencyResolver { private readonly Dictionary<Type, Props> _registrations = new Dictionary<Type, Props>(); public void Register<T>(Props instance) { _registrations.Add(typeof(T), instance); } public Type GetType(string actorName) { throw new NotImplementedException(); } public Func<ActorBase> CreateActorFactory(Type actorType) { return () => Create(actorType).NewActor(); } public Props Create<TActor>() where TActor : ActorBase { return _registrations[typeof (TActor)]; } public Props Create(Type actorType) { return _registrations[actorType]; } public void Release(ActorBase actor) { } }