public void Setup() { var scoreCalculator = new SimpleScoreCalculator(); _scoreQuery = new ScoreQuery(new Mock<ISignaler>().Object, scoreCalculator); var eventBus = new DomainBus(); eventBus.RegisterHandler(() => new GameHandler(_scoreQuery)); var eventStorage = new InMemoryEventStorage(); var sessionFactory = new SessionFactory(eventStorage); var gameService = new GameService(sessionFactory, eventBus); _commandbus = new DomainBus(); _commandbus.RegisterHandler(() => gameService); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { var scoreCalculator = new EloCalculator(); var scoreQuery = new ScoreQuery(new WebSignaler(), scoreCalculator); var eventBus = new DomainBus(); var teamService = new TeamService(); eventBus.RegisterHandler(() => new GameHandler(scoreQuery)); eventBus.RegisterHandler(() => teamService); kernel.Bind<IScoreQuery>().ToConstant(scoreQuery); kernel.Bind<ITeamService>().ToConstant(teamService); var eventStorage = GetEventStorage(eventBus); var sessionFactory = new SessionFactory(eventStorage); kernel.Bind<IEventStorage>().ToConstant(eventStorage); kernel.Bind<ISessionFactory>().ToConstant(sessionFactory); var gameService = new GameService(sessionFactory, eventBus); var commandbus = new DomainBus(); commandbus.RegisterHandler(() => gameService); kernel.Bind<IBus>().ToConstant(commandbus); }