Exemple #1
0
        public void WebJobsShutdown_WhenUsingTriggeredFunction_TriggersCancellationToken()
        {
            using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext())
                using (JobHost host = new JobHost(_hostConfiguration))
                {
                    _invokeInFunction = () => { shutdownContext.NotifyShutdown(); };

                    PrepareHostForTrigger(host, startHost: true);

                    EvaluateTriggeredCancellation(expectedCancellation: true);
                }
        }
Exemple #2
0
        public void WebJobsShutdown_WhenUsingHostCall_TriggersCancellationToken()
        {
            using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext())
                using (JobHost host = new JobHost(_hostConfiguration))
                {
                    _invokeInFunction = () => { shutdownContext.NotifyShutdown(); };

                    Task callTask = InvokeNoAutomaticTriggerFunction(host);

                    EvaluateNoAutomaticTriggerCancellation(callTask, expectedCancellation: true);
                }
        }
Exemple #3
0
        public async Task WebJobsShutdown_WhenUsingTriggeredFunction_TriggersCancellationToken()
        {
            using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext())
                using (_host)
                {
                    JobHost jobHost = _host.GetJobHost();
                    _invokeInFunction = () => { shutdownContext.NotifyShutdown(); };

                    await PrepareHostForTriggerAsync(jobHost, startHost : true);

                    EvaluateTriggeredCancellation(expectedCancellation: true);
                }
        }
Exemple #4
0
        public void Signaled()
        {
            using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext())
                using (var watcher = new WebJobsShutdownWatcher())
                {
                    var token = watcher.Token;
                    Assert.True(!token.IsCancellationRequested);

                    // Write the file
                    shutdownContext.NotifyShutdown();

                    // Token should be signaled very soon
                    Assert.True(token.WaitHandle.WaitOne(500));
                }
        }
Exemple #5
0
        public void NotSignaledAfterDisposed()
        {
            using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext())
            {
                CancellationToken token;
                using (var watcher = new WebJobsShutdownWatcher())
                {
                    token = watcher.Token;
                    Assert.True(!token.IsCancellationRequested);
                }
                // Write the file
                shutdownContext.NotifyShutdown();

                Assert.True(!token.IsCancellationRequested);
            }
        }
        public void WebJobsShutdown_WhenUsingHostCall_TriggersCancellationToken()
        {
            // Run test in multithreaded environment
            var oldContext = SynchronizationContext.Current;

            try
            {
                SynchronizationContext.SetSynchronizationContext(null);
                using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext())
                    using (JobHost host = new JobHost(_hostConfiguration))
                    {
                        _invokeInFunction = () => { shutdownContext.NotifyShutdown(); };

                        Task callTask = InvokeNoAutomaticTriggerFunction(host);

                        EvaluateNoAutomaticTriggerCancellation(callTask, expectedCancellation: true);
                    }
            }
            finally
            {
                SynchronizationContext.SetSynchronizationContext(oldContext);
            }
        }