public void ShouldCancelRequest()
        {
            // given
            const int jobKey = 255;

            // when
            var task = ZeebeClient
                       .NewFailCommand(jobKey)
                       .Retries(2)
                       .ErrorMessage("This job failed!")
                       .Send(new CancellationTokenSource(TimeSpan.Zero).Token);
            var aggregateException = Assert.Throws <AggregateException>(() => task.Wait());
            var rpcException       = (RpcException)aggregateException.InnerExceptions[0];

            // then
            Assert.AreEqual(StatusCode.Cancelled, rpcException.Status.StatusCode);
        }
Ejemplo n.º 2
0
        public void ShouldTimeoutRequest()
        {
            // given
            const int JobKey = 255;

            // when
            var task = ZeebeClient
                       .NewFailCommand(JobKey)
                       .Retries(2)
                       .ErrorMessage("This job failed!")
                       .Send(TimeSpan.Zero);
            var aggregateException = Assert.Throws <AggregateException>(() => task.Wait());
            var rpcException       = (RpcException)aggregateException.InnerExceptions[0];

            // then
            Assert.AreEqual(Grpc.Core.StatusCode.DeadlineExceeded, rpcException.Status.StatusCode);
        }
        public async Task ShouldSendRequestAsExpected()
        {
            // given
            const string errorMessage    = "This job failed!";
            const int    jobKey          = 255;
            var          expectedRequest = new FailJobRequest
            {
                JobKey       = jobKey,
                ErrorMessage = errorMessage,
                Retries      = 2
            };

            // when
            await ZeebeClient.NewFailCommand(jobKey).Retries(2).ErrorMessage("This job failed!").Send();

            // then
            var actualRequest = TestService.Requests[typeof(FailJobRequest)][0];

            Assert.AreEqual(expectedRequest, actualRequest);
        }