private bool Handle(PurchaseBookCommand command) { var provider = DependencyInjectorStub.Get((s, c) => { BootStrapper.RegisterServices(s, c); s.AddScoped(x => MockRepository.GetContext()); s.AddScoped <IBusPublisher>(x => Bus); s.AddScoped <IDateTimeService>(x => DateTimeServiceStub.Create()); }); var handler = provider.GetRequiredService <IRequestHandler <PurchaseBookCommand, bool> >(); return(handler.Handle(command, CancellationToken.None).GetAwaiter().GetResult()); }
public TelemetryServiceTest() { _dateTimeServiceStub = new DateTimeServiceStub { Now = DateTime.Now }; _httpContext = new DefaultHttpContext { Request = { Method = "GET", Protocol = "http", Host = new HostString("localhost", 80), Path = PathString.FromUriComponent("/budgets/06/2016") } }; _exceptionRepository = new InMemoryRepository <TelemetryException>(); _eventRepository = new InMemoryRepository <TelemetryEvent>(); _timingRepository = new InMemoryRepository <TelemetryTiming>(); _telemetryService = new TelemetryService(_exceptionRepository, _eventRepository, _timingRepository, _dateTimeServiceStub); }