コード例 #1
0
        public AutoCheckPointTests()
        {
            changeFeedObserver    = Mock.Of <IChangeFeedObserver>();
            partitionCheckpointer = Mock.Of <IPartitionCheckpointer>();
            Mock.Get(partitionCheckpointer)
            .Setup(checkPointer => checkPointer.CheckpointPartitionAsync(It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            checkpointFrequency = new CheckpointFrequency();
            sut = new AutoCheckpointer(checkpointFrequency, changeFeedObserver);

            documents    = Mock.Of <IReadOnlyList <Document> >();
            feedResponse = Mock.Of <IFeedResponse <Document> >();
            Mock.Get(feedResponse)
            .Setup(response => response.Count)
            .Returns(documents.Count);
            Mock.Get(feedResponse)
            .Setup(response => response.ResponseContinuation)
            .Returns("token");
            Mock.Get(feedResponse)
            .Setup(response => response.GetEnumerator())
            .Returns(documents.GetEnumerator());

            observerContext = Mock.Of <IChangeFeedObserverContext>();
            Mock.Get(observerContext)
            .Setup(context => context.CheckpointAsync())
            .Returns(partitionCheckpointer.CheckpointPartitionAsync("token"));
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CheckpointerObserverFactory"/> class.
        /// </summary>
        /// <param name="observerFactory">Instance of Observer Factory</param>
        /// <param name="checkpointFrequency">Defined <see cref="CheckpointFrequency"/></param>
        public CheckpointerObserverFactory(IChangeFeedObserverFactory observerFactory, CheckpointFrequency checkpointFrequency)
        {
            if (observerFactory == null)
            {
                throw new ArgumentNullException(nameof(observerFactory));
            }
            if (checkpointFrequency == null)
            {
                throw new ArgumentNullException(nameof(checkpointFrequency));
            }

            this.observerFactory     = observerFactory;
            this.checkpointFrequency = checkpointFrequency;
        }
コード例 #3
0
        public AutoCheckpointer(CheckpointFrequency checkpointFrequency, ChangeFeedObserver <T> observer)
        {
            if (checkpointFrequency == null)
            {
                throw new ArgumentNullException(nameof(checkpointFrequency));
            }
            if (observer == null)
            {
                throw new ArgumentNullException(nameof(observer));
            }

            this.checkpointFrequency = checkpointFrequency;
            this.observer            = observer;
        }
コード例 #4
0
        public void ValidateLegacyOptionsAreUsed()
        {
            DateTime startTime   = DateTime.Now;
            var      feedOptions = new ChangeFeedOptions
            {
                MaxItemCount        = 1,
                StartFromBeginning  = true,
                StartTime           = startTime,
                RequestContinuation = "RequestContinuation",
                SessionToken        = "SessionToken",
            };

            var checkpointFrequency = new CheckpointFrequency {
                ExplicitCheckpoint = true
            };
            var hostOptions = new ChangeFeedHostOptions
            {
                LeaseRenewInterval          = TimeSpan.FromSeconds(2),
                LeaseAcquireInterval        = TimeSpan.FromSeconds(3),
                LeaseExpirationInterval     = TimeSpan.FromSeconds(4),
                FeedPollDelay               = TimeSpan.FromSeconds(5),
                CheckpointFrequency         = checkpointFrequency,
                LeasePrefix                 = "LeasePrefix",
                MinPartitionCount           = 6,
                MaxPartitionCount           = 7,
                QueryPartitionsMaxBatchSize = 8,
            };

            var processorOptions = ChangeFeedEventHost.CreateProcessorOptions(feedOptions, hostOptions);

            Assert.Equal(1, processorOptions.MaxItemCount);
            Assert.True(processorOptions.StartFromBeginning);
            Assert.Equal(startTime, processorOptions.StartTime);
            Assert.Equal("RequestContinuation", processorOptions.RequestContinuation);
            Assert.Equal("SessionToken", processorOptions.SessionToken);
            Assert.Equal(TimeSpan.FromSeconds(2), processorOptions.LeaseRenewInterval);
            Assert.Equal(TimeSpan.FromSeconds(3), processorOptions.LeaseAcquireInterval);
            Assert.Equal(TimeSpan.FromSeconds(4), processorOptions.LeaseExpirationInterval);
            Assert.Equal(TimeSpan.FromSeconds(5), processorOptions.FeedPollDelay);
            Assert.Equal(checkpointFrequency, processorOptions.CheckpointFrequency);
            Assert.Equal("LeasePrefix", processorOptions.LeasePrefix);
            Assert.Equal(6, processorOptions.MinPartitionCount);
            Assert.Equal(7, processorOptions.MaxPartitionCount);
            Assert.Equal(8, processorOptions.QueryPartitionsMaxBatchSize);
        }
コード例 #5
0
        public AutoCheckPointTests()
        {
            changeFeedObserver    = Mock.Of <ChangeFeedObserver <dynamic> >();
            partitionCheckpointer = Mock.Of <PartitionCheckpointer>();
            Mock.Get(partitionCheckpointer)
            .Setup(checkPointer => checkPointer.CheckpointPartitionAsync(It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            checkpointFrequency = new CheckpointFrequency();
            sut = new AutoCheckpointer <dynamic>(checkpointFrequency, changeFeedObserver);

            documents = Mock.Of <IReadOnlyList <dynamic> >();

            observerContext = Mock.Of <ChangeFeedObserverContext>();
            Mock.Get(observerContext)
            .Setup(context => context.CheckpointAsync())
            .Returns(partitionCheckpointer.CheckpointPartitionAsync("token"));
        }