public async Task ShouldSendRequestAsExpected() { // given TopologyRequest expectedRequest = new TopologyRequest(); // when await ZeebeClient.TopologyRequest().Send(); // then var actualRequest = TestService.Requests[0]; Assert.AreEqual(expectedRequest, actualRequest); }
public void ShouldCancelRequest() { // given // when var task = ZeebeClient .TopologyRequest() .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 void ShouldTimeoutRequest() { // given // when var task = ZeebeClient .TopologyRequest() .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 ShouldUseUserAgentHeader() { // given Metadata sendMetadata = null; TestService.ConsumeRequestHeaders(metadata => { sendMetadata = metadata; }); // when await ZeebeClient.TopologyRequest().Send(); // then Assert.NotNull(sendMetadata); var entry = sendMetadata[0]; Assert.AreEqual("user-agent", entry.Key); Assert.IsTrue(entry.Value.StartsWith("zeebe-client-csharp/" + typeof(ZeebeClient).Assembly.GetName().Version)); }
public async Task ShouldReceiveResponseAsExpected() { // given TopologyResponse expectedResponse = new TopologyResponse(); expectedResponse.Brokers.Add(CreateBrokerInfo(0, "host", 26501, 0, true)); expectedResponse.Brokers.Add(CreateBrokerInfo(1, "host", 26501, 0, false)); expectedResponse.Brokers.Add(CreateBrokerInfo(2, "host", 26501, 0, false)); TestService.AddRequestHandler(typeof(TopologyRequest), (request) => expectedResponse); // when ITopology response = await ZeebeClient.TopologyRequest().Send(); // then IBrokerInfo firstBroker = response.Brokers[0]; Assert.AreEqual("host0:26501", firstBroker.Address); Assert.AreEqual(0, firstBroker.NodeId); IPartitionInfo firstPartition = firstBroker.Partitions[0]; Assert.AreEqual(0, firstPartition.PartitionId); Assert.AreEqual(PartitionBrokerRole.LEADER, firstPartition.Role); IBrokerInfo secondBroker = response.Brokers[1]; Assert.AreEqual("host1:26501", secondBroker.Address); Assert.AreEqual(1, secondBroker.NodeId); firstPartition = secondBroker.Partitions[0]; Assert.AreEqual(0, firstPartition.PartitionId); Assert.AreEqual(PartitionBrokerRole.FOLLOWER, firstPartition.Role); IBrokerInfo thirdBroker = response.Brokers[2]; Assert.AreEqual("host2:26501", thirdBroker.Address); Assert.AreEqual(2, thirdBroker.NodeId); firstPartition = thirdBroker.Partitions[0]; Assert.AreEqual(0, firstPartition.PartitionId); Assert.AreEqual(PartitionBrokerRole.FOLLOWER, firstPartition.Role); }