// This method gets called by the runtime.
 // Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddBookStore(Configuration, _loggerFactory);
     var bookDetailLookup = new BookDetailLookup(
         Configuration.GetOrThrow("GOOGLE_PROJECT_ID"), _loggerFactory);
     bookDetailLookup.StartPullLoop(
         services.BuildServiceProvider().GetService<IBookStore>(),
         new CancellationTokenSource().Token);
 }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);

            // Launch a thread that watches the book detail subscription.
            var container = App_Start.UnityConfig.GetConfiguredContainer();
            var bookDetailLookup = new BookDetailLookup(LibUnityConfig.ProjectId);
            bookDetailLookup.CreateTopicAndSubscription();
            var pullTask = bookDetailLookup.StartPullLoop(container.Resolve<IBookStore>(),
                new CancellationTokenSource().Token);
        }
 public void TestLoop()
 {
     var options = new BookDetailLookup.Options();
     options.SubscriptionName += "-test";
     options.TopicName += "-test";
     BookDetailLookup bookDetailLookup =
         new BookDetailLookup(_projectId, new LoggerFactory(), options);
     bookDetailLookup.CreateTopicAndSubscription();
     var cancel = new CancellationTokenSource();
     var pullTask = bookDetailLookup.StartPullLoop(new FakeBookStore(), cancel.Token);
     cancel.CancelAfter(100);
     pullTask.Wait();
 }