示例#1
0
        public void CanBuildWithCosmosLeaseContainer()
        {
            ChangeFeedProcessorBuilder builder = new ChangeFeedProcessorBuilder("workflowName",
                                                                                ChangeFeedProcessorBuilderTests.GetMockedContainer(),
                                                                                ChangeFeedProcessorBuilderTests.GetMockedProcessor(),
                                                                                ChangeFeedProcessorBuilderTests.GetEmptyInitialization());

            builder.WithLeaseContainer(ChangeFeedProcessorBuilderTests.GetMockedContainer());

            Assert.IsInstanceOfType(builder.Build(), typeof(ChangeFeedProcessor));
        }
        public void CannotBuildTwice()
        {
            ChangeFeedProcessorBuilder builder = new ChangeFeedProcessorBuilder("workflowName",
                                                                                ChangeFeedProcessorBuilderTests.GetMockedContainer(),
                                                                                ChangeFeedProcessorBuilderTests.GetMockedProcessor(),
                                                                                ChangeFeedProcessorBuilderTests.GetEmptyInitialization());

            builder.WithLeaseContainer(ChangeFeedProcessorBuilderTests.GetMockedContainer());

            // This build should not throw
            builder.Build();

            // This one should
            Assert.ThrowsException <InvalidOperationException>(() => builder.Build());
        }
        public void WithLeaseConfigurationFillsCorrectValues()
        {
            TimeSpan acquireInterval    = TimeSpan.FromSeconds(1);
            TimeSpan expirationInterval = TimeSpan.FromSeconds(2);
            TimeSpan renewInterval      = TimeSpan.FromSeconds(3);
            string   workflowName       = "workflowName";


            Action <DocumentServiceLeaseStoreManager,
                    CosmosContainer,
                    string,
                    string,
                    ChangeFeedLeaseOptions,
                    ChangeFeedProcessorOptions,
                    CosmosContainer> verifier = (DocumentServiceLeaseStoreManager leaseStoreManager,
                                                 CosmosContainer leaseContainer,
                                                 string leaseContainerPrefix,
                                                 string instanceName,
                                                 ChangeFeedLeaseOptions changeFeedLeaseOptions,
                                                 ChangeFeedProcessorOptions changeFeedProcessorOptions,
                                                 CosmosContainer monitoredContainer) =>
            {
                Assert.AreEqual(workflowName, changeFeedLeaseOptions.LeasePrefix);
                Assert.AreEqual(acquireInterval, changeFeedLeaseOptions.LeaseAcquireInterval);
                Assert.AreEqual(expirationInterval, changeFeedLeaseOptions.LeaseExpirationInterval);
                Assert.AreEqual(renewInterval, changeFeedLeaseOptions.LeaseRenewInterval);
            };

            ChangeFeedProcessorBuilder builder = new ChangeFeedProcessorBuilder(workflowName,
                                                                                ChangeFeedProcessorBuilderTests.GetMockedContainer(),
                                                                                ChangeFeedProcessorBuilderTests.GetMockedProcessor(),
                                                                                verifier);

            builder.WithLeaseContainer(ChangeFeedProcessorBuilderTests.GetMockedContainer());
            builder.WithLeaseConfiguration(acquireInterval, expirationInterval, renewInterval);

            builder.Build();
        }