public async Task ShouldSendRequestReceiveResponseAsExpected()
        {
            // given
            var expectedRequest = new ActivateJobsRequest
            {
                Timeout           = 10_000L,
                MaxJobsToActivate = 1,
                Type   = "foo",
                Worker = "jobWorker",
            };

            TestService.AddRequestHandler(typeof(ActivateJobsRequest), request => CreateExpectedResponse());

            // when
            var response = await ZeebeClient.NewActivateJobsCommand()
                           .JobType("foo")
                           .MaxJobsToActivate(1)
                           .Timeout(TimeSpan.FromSeconds(10))
                           .WorkerName("jobWorker")
                           .Send();

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

            Assert.AreEqual(expectedRequest, actualRequest);

            var receivedJobs = response.Jobs;

            Assert.AreEqual(receivedJobs.Count, 3);

            AssertJob(receivedJobs[0], 1);
            AssertJob(receivedJobs[1], 2);
            AssertJob(receivedJobs[2], 3);
        }
示例#2
0
        public void ShouldCancelRequest()
        {
            // given

            // when
            var task = ZeebeClient.NewActivateJobsCommand()
                       .JobType("foo")
                       .MaxJobsToActivate(1)
                       .Timeout(TimeSpan.FromSeconds(10))
                       .WorkerName("jobWorker")
                       .PollingTimeout(TimeSpan.FromSeconds(5))
                       .Send(new CancellationTokenSource(TimeSpan.Zero).Token);
            var aggregateException = Assert.Throws <AggregateException>(() => task.Wait());
            var rpcException       = (RpcException)aggregateException.InnerExceptions[0];

            // then
            Assert.AreEqual(Grpc.Core.StatusCode.Cancelled, rpcException.Status.StatusCode);
        }