-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added unit test to check expected requests for UpdateJobTimeout…
…Command
- Loading branch information
1 parent
0b294e0
commit 87e1684
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using GatewayProtocol; | ||
using Grpc.Core; | ||
using NUnit.Framework; | ||
|
||
namespace Zeebe.Client; | ||
|
||
[TestFixture] | ||
public class UpdateJobTimeoutTest : BaseZeebeTest | ||
{ | ||
[Test] | ||
public async Task ShouldSendRequestAsExpected() | ||
{ | ||
// given | ||
var expectedRequest = new UpdateJobTimeoutRequest() | ||
{ | ||
JobKey = 1024, | ||
Timeout = 2000 | ||
}; | ||
|
||
// when | ||
await ZeebeClient | ||
.NewUpdateJobTimeoutCommand(1024) | ||
.Timeout(new TimeSpan(0, 0, 2)) | ||
.Send(); | ||
|
||
// then | ||
var request = TestService.Requests[typeof(UpdateJobTimeoutRequest)][0]; | ||
Assert.AreEqual(expectedRequest, request); | ||
} | ||
|
||
[Test] | ||
public void ShouldTimeoutRequest() | ||
{ | ||
// given | ||
|
||
// when | ||
var task = ZeebeClient | ||
.NewUpdateJobTimeoutCommand(1024) | ||
.Timeout(new TimeSpan(0, 0, 2)) | ||
.Send(TimeSpan.Zero); | ||
var aggregateException = Assert.Throws<AggregateException>(() => task.Wait()); | ||
var rpcException = (RpcException)aggregateException.InnerExceptions[0]; | ||
|
||
// then | ||
Assert.AreEqual(StatusCode.DeadlineExceeded, rpcException.Status.StatusCode); | ||
} | ||
|
||
[Test] | ||
public void ShouldCancelRequest() | ||
{ | ||
// given | ||
|
||
// when | ||
var task = ZeebeClient | ||
.NewUpdateJobTimeoutCommand(1024) | ||
.Timeout(new TimeSpan(0, 0, 2)) | ||
.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); | ||
} | ||
} |