コード例 #1
0
        public void ApplyBuildConfiguration_ValidatesNullMonitoredContainer()
        {
            Func <long, CancellationToken, Task> estimationDelegate = (long estimation, CancellationToken token) =>
            {
                return(Task.CompletedTask);
            };

            ChangeFeedEstimatorCore estimator = ChangeFeedEstimatorCoreTests.CreateEstimator(estimationDelegate, out Mock <RemainingWorkEstimator> remainingWorkEstimator);

            estimator.ApplyBuildConfiguration(
                null,
                ChangeFeedEstimatorCoreTests.GetMockedContainer("leases"),
                "something",
                "instanceName",
                new ChangeFeedLeaseOptions(),
                new ChangeFeedProcessorOptions(),
                null);
        }
コード例 #2
0
        public void ApplyBuildConfiguration_ValidCustomStore()
        {
            Func <long, CancellationToken, Task> estimationDelegate = (long estimation, CancellationToken token) =>
            {
                return(Task.CompletedTask);
            };

            ChangeFeedEstimatorCore estimator = ChangeFeedEstimatorCoreTests.CreateEstimator(estimationDelegate, out Mock <RemainingWorkEstimator> remainingWorkEstimator);

            estimator.ApplyBuildConfiguration(
                Mock.Of <DocumentServiceLeaseStoreManager>(),
                null,
                "something",
                "instanceName",
                new ChangeFeedLeaseOptions(),
                new ChangeFeedProcessorOptions(),
                ChangeFeedEstimatorCoreTests.GetMockedContainer("monitored"));
        }
コード例 #3
0
        public async Task StartAsync_TriggersDelegate()
        {
            const long remainingWork           = 15;
            long       estimationDelegateValue = 0;
            bool       receivedEstimation      = false;
            Func <long, CancellationToken, Task> estimationDelegate = (long estimation, CancellationToken token) =>
            {
                estimationDelegateValue = estimation;
                receivedEstimation      = true;
                return(Task.CompletedTask);
            };

            Mock <DocumentServiceLeaseStoreManager> leaseStoreManager = new Mock <DocumentServiceLeaseStoreManager>();

            leaseStoreManager.Setup(l => l.LeaseContainer).Returns(Mock.Of <DocumentServiceLeaseContainer>);
            leaseStoreManager.Setup(l => l.LeaseManager).Returns(Mock.Of <DocumentServiceLeaseManager>);
            leaseStoreManager.Setup(l => l.LeaseStore).Returns(Mock.Of <DocumentServiceLeaseStore>);
            leaseStoreManager.Setup(l => l.LeaseCheckpointer).Returns(Mock.Of <DocumentServiceLeaseCheckpointer>);

            ChangeFeedEstimatorCore estimator = ChangeFeedEstimatorCoreTests.CreateEstimator(estimationDelegate, out Mock <RemainingWorkEstimator> remainingWorkEstimator);

            estimator.ApplyBuildConfiguration(
                leaseStoreManager.Object,
                null,
                "something",
                "instanceName",
                new ChangeFeedLeaseOptions(),
                new ChangeFeedProcessorOptions(),
                ChangeFeedEstimatorCoreTests.GetMockedContainer("monitored"));

            remainingWorkEstimator.Setup(r => r.GetEstimatedRemainingWorkAsync(It.IsAny <CancellationToken>())).ReturnsAsync(remainingWork);

            await estimator.StartAsync();

            int waitIterations = 0; // Failsafe in case someone breaks the estimator so this does not run forever

            while (!receivedEstimation && waitIterations++ < 3)
            {
                Thread.Sleep(TimeSpan.FromSeconds(10));
            }

            Assert.AreEqual(remainingWork, estimationDelegateValue);
        }
コード例 #4
0
 public void NullDelegateThrows()
 {
     ChangeFeedEstimatorCoreTests.CreateEstimator(null, out Mock <RemainingWorkEstimator> remainingWorkEstimator);
 }