/// <summary> /// Initializes a new instance of the <see cref="SimpleBingCommercePusher"/> class. /// </summary> /// <param name="config">The pusher configurations object</param> /// <param name="checkpoint">The checkpoint to poll the data since if it's valid.</param> /// <param name="serializer">(Optional): Explicit serialier to be used.</param> public SimpleBingCommercePusher(BingCommerceConfig config, IDataCheckpoint checkpoint, IPushSerializer <IDictionary <string, object> > serializer = null) { var sdkClient = new BingCommerceIngestion(new TokenCredentials(config.AccessToken)); var logger = new RequestLogger(config.RequestLogLocation, config.RequestLog); this.config = config; this.client = new IngestionClient(sdkClient, config.TenantId, config.IndexId, config.RetryCount, logger); this.tracker = new StatusTracker(this.client, config.TrackingInterval, logger); this.taskManager = new TaskManager(config.MaxConcurrentRequests); this.checkpointAcceptor = new CheckpointAcceptor(checkpoint); this.Serializer = serializer ?? new FormatSerializer(config.PushFormat); log.Debug("Successfully created the Simple Bing Commerce Pusher with the provided access token."); }
public void TestCheckpointAcceptor() { var testCheckpoint = new TestCheckpoint(); var acceptor = new CheckpointAcceptor(testCheckpoint); acceptor.Pending("1"); acceptor.Pending("2"); acceptor.Accept("2"); Assert.IsFalse(testCheckpoint.IsValid()); acceptor.Accept("1"); Assert.IsTrue(testCheckpoint.IsValid()); Assert.AreEqual("2", testCheckpoint.GetValue()); }