Exemple #1
0
        public void Sends_heartbeat_to_amazon_swf_when_started()
        {
            var heartbeatApi = new TestHeartbeatSwfApi(() => false);

            StartHearbeat(heartbeatApi);
            Assert.That(heartbeatApi.Details, Is.EqualTo(HearbeatDetails));
        }
Exemple #2
0
        public void Do_not_send_hearbeat_to_amazon_swf_when_no_interval_is_set()
        {
            var heartbeatApi = new TestHeartbeatSwfApi(() => false);
            var hearbeat     = new ActivityHeartbeat();

            hearbeat.StartHeartbeatIfEnabled(heartbeatApi, "token");

            Assert.IsFalse(heartbeatApi.Wait(HeartbeatIntervel * 100));
            Assert.That(heartbeatApi.HearbeatRecorded, Is.False);
        }
Exemple #3
0
        public async Task Heartbeat_started_when_it_it_enabled_on_activity_programmatically()
        {
            var hearbeatApi = new TestHeartbeatSwfApi(() => false);
            var activity    = new ActivityWithHeartbeatEnabledProgrammatically("details", TimeSpan.FromSeconds(5));

            activity.SetSwfApi(hearbeatApi);
            await activity.ExecuteAsync(_activityArgs);

            Assert.IsTrue(hearbeatApi.Wait(WaitPeriod));
            Assert.That(hearbeatApi.Details, Is.EqualTo("details"));
        }
Exemple #4
0
        public async Task Does_not_send_hearbeat_to_amazon_swf_when_not_enabled()
        {
            var hearbeatApi = new TestHeartbeatSwfApi(() => false);
            var activity    = new ActivityWithoutHearbeat("details", TimeSpan.FromSeconds(5));

            activity.SetSwfApi(hearbeatApi);
            await activity.ExecuteAsync(_activityArgs);

            Assert.IsFalse(hearbeatApi.Wait(HeartbeatInterval * 100));
            Assert.IsFalse(hearbeatApi.HearbeatRecorded);
        }
Exemple #5
0
        public void Raise_cancellation_requested_when_activity_is_requested_to_cancel()
        {
            var heartbeatApi = new TestHeartbeatSwfApi(() => true);
            var cancellelationRequestedEvent = new ManualResetEvent(false);

            _activityHearbeat.CancellationRequested += (s, e) => cancellelationRequestedEvent.Set();

            StartHearbeat(heartbeatApi);

            Assert.That(cancellelationRequestedEvent.WaitOne(WaitPeriod), "Cancellation request event is not raised");
        }
Exemple #6
0
        public async Task Cancellation_token_is_set_when_heartbeat_returns_cancellation_request()
        {
            var hearbeatApi = new TestHeartbeatSwfApi(() => true, setEventOnCalledTimes: 2);
            var activity    = new ActivityWithCancellationToken(executionTime: TimeSpan.FromSeconds(1));

            activity.SetSwfApi(hearbeatApi);

            await activity.ExecuteAsync(_activityArgs);

            Assert.IsTrue(hearbeatApi.Wait(WaitPeriod));
            Assert.That(activity.CancellationRequested, Is.True);
        }
Exemple #7
0
 private void StartHearbeat(TestHeartbeatSwfApi heartbeatApi)
 {
     try
     {
         _activityHearbeat.StartHeartbeatIfEnabled(heartbeatApi, "token");
         Assert.IsTrue(heartbeatApi.Wait(WaitPeriod));
     }
     finally
     {
         _activityHearbeat.StopHeartbeat();
     }
 }