private static async void Run(IConfigurationRoot configuration) { var reelsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configuration.GetSection("reelsPath").Value); var scoresPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configuration.GetSection("scoresPath").Value); var wordsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configuration.GetSection("wordsPath").Value); var gameRepository = new FileGameDataSource(reelsPath, scoresPath, wordsPath); var eventDomainDispatcher = new EventDomainDispatcher(); eventDomainDispatcher.Add <OnUserStartedGame, ConsoleOnUserStartedGame>(new ConsoleOnUserStartedGame()); eventDomainDispatcher.Add <OnUserFinishedPlay, ConsoleOnUserFinishedPlay>(new ConsoleOnUserFinishedPlay()); eventDomainDispatcher.Add <OnUserStartedNextPlay, ConsoleOnUserStartedNextPlay>(new ConsoleOnUserStartedNextPlay()); var trieFactory = new TrieWorldImplementationFactory(); var game = await new DefaultGameFactory(gameRepository, trieFactory, eventDomainDispatcher).Create(); game.Init(); while (game.IsPlaying) { var input = Console.ReadLine(); game.Play(input); } }
public void CallsDiferentDomainEvents() { var eventDispatcher = new EventDomainDispatcher(); var implementationOneEventOne = Substitute.For <ImplementationOneEventOne>(); var implementationOneEventTwo = Substitute.For <ImplementationOneEventTwo>(); eventDispatcher.Add <EventOne, ImplementationOneEventOne>(implementationOneEventOne); eventDispatcher.Add <EventTwo, ImplementationOneEventTwo>(implementationOneEventTwo); eventDispatcher.Send(new EventOne()); implementationOneEventOne.Received(1).Execute(Arg.Any <EventOne>()); implementationOneEventTwo.Received(1).Execute(Arg.Any <EventTwo>()); }
public void CallsSameInstanceRegistrations() { var eventDispatcher = new EventDomainDispatcher(); var instanceOne = Substitute.For <ImplementationOneEventOne>(); var instanceTwo = Substitute.For <ImplementationOneEventOne>(); eventDispatcher.Add <EventOne, ImplementationOneEventOne>(instanceOne); eventDispatcher.Add <EventOne, ImplementationOneEventOne>(instanceTwo); eventDispatcher.Send(new EventOne()); instanceOne.Received(1).Execute(Arg.Any <EventOne>()); instanceTwo.Received(1).Execute(Arg.Any <EventOne>()); }