Proper TDD + Dependency Injection in Akka.net -


i have , agent, read directory x , create child agent each subdirectory finds.

to testing enviroment i've used system.io.abstractions package creates ifilesystem interface , it's implementation (for normal program use).

agent (for dir x) uses autofac di create child agents (since need give them ifilesystem dependency, , more in future):

var props = context.di().props<directoryreader>(); var directoryagent = context.actorof(props, "directoryreader"); 

my tests looks this:

public class directoryreadertests : akka.testkit.xunit2.testkit  {     public directoryreadertests()         : base(@"akka.loglevel = debug")     {         var builder = new containerbuilder();         builder.registertype<filesystem>().as<ifilesystem>();          var container = builder.build();  // <--- how use testkit     }      [fact]     public void createsagentforeachsubdirectory()     {         eventfilter.info()             .expect(3, () => gettargetagent(existingdirpath));     }      private testactorref<directoryreader> gettargetagent(string path)     {         var filesystem = getmockfilesystem();         var target = actorofastestactorref<directoryreader>(             props.create(                 () =>                     new directoryreader(                         databaser,                         filesystem.object                         )));         target.tell(new hashdirectory(path));         return target;     } } 

now question is: how tell testkit use container dependency injection


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -