Exemplo n.º 1
0
        public async Task ShouldUseActivatedJobToComplete()
        {
            // given
            const string Variables = "{\"foo\":23}";
            const int    JobKey    = 255;

            var grpcActivatedJob = new ActivatedJob();

            grpcActivatedJob.Key        = JobKey;
            grpcActivatedJob.JobHeaders = new JobHeaders();
            var activatedJob    = new Impl.Responses.ActivatedJob(grpcActivatedJob);
            var expectedRequest = new CompleteJobRequest
            {
                JobKey    = JobKey,
                Variables = Variables
            };

            // when
            await ZeebeClient.NewCompleteJobCommand(activatedJob).Variables(Variables).Send();

            // then
            var actualRequest = TestService.Requests[0];

            Assert.AreEqual(expectedRequest, actualRequest);
        }
        public void ShouldCancelRequest()
        {
            // given
            const string variables = "{\"foo\":23}";
            const int    jobKey    = 255;

            // when
            var task = ZeebeClient.NewCompleteJobCommand(jobKey).Variables(variables).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);
        }
        public async Task ShouldSendRequestAsExpected()
        {
            // given
            const string Variables       = "{\"foo\":23}";
            const int    JobKey          = 255;
            var          expectedRequest = new CompleteJobRequest
            {
                JobKey    = JobKey,
                Variables = Variables
            };

            // when
            await ZeebeClient.NewCompleteJobCommand(JobKey).Variables(Variables).Send();

            // then
            var actualRequest = TestService.Requests[0];

            Assert.AreEqual(expectedRequest, actualRequest);
        }