-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(worker): add test for job worker
- Loading branch information
Showing
12 changed files
with
176 additions
and
34 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
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
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
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
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
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,62 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using GatewayProtocol; | ||
using Zeebe.Client.Impl.Responses; | ||
using Zeebe.Client.Api.Responses; | ||
using System.Diagnostics.Contracts; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Grpc.Core; | ||
using Zeebe.Client.Api.Subscription; | ||
|
||
|
||
namespace Zeebe.Client | ||
{ | ||
[TestFixture] | ||
public class JobWorkerTest : BaseZeebeTest | ||
{ | ||
[Test] | ||
public async Task ShouldSendRequestAsExpected() | ||
{ | ||
// given | ||
var expectedRequest = new ActivateJobsRequest | ||
{ | ||
Timeout = 123L, Amount = 1, Type = "foo", Worker = "jobWorker" | ||
}; | ||
|
||
var expectedResponse = new ActivateJobsResponse | ||
{ | ||
Jobs = | ||
{ | ||
new GatewayProtocol.ActivatedJob{Key = 1, JobHeaders = new GatewayProtocol.JobHeaders()}, | ||
new GatewayProtocol.ActivatedJob{Key = 2, JobHeaders = new GatewayProtocol.JobHeaders()}, | ||
new GatewayProtocol.ActivatedJob{Key = 3, JobHeaders = new GatewayProtocol.JobHeaders()} | ||
} | ||
}; | ||
|
||
TestService.AddRequestHandler(typeof(ActivateJobsRequest), request => expectedResponse); | ||
|
||
// when | ||
var signal = new EventWaitHandle(false, EventResetMode.AutoReset); | ||
using (var jobWorker = ZeebeClient.JobClient() | ||
.Worker() | ||
.JobType("foo") | ||
.Handler((jobClient, job) => { signal.Set(); }) | ||
.Limit(1) | ||
.Name("jobWorker") | ||
.Timeout(123L) | ||
.PollInterval(TimeSpan.FromMilliseconds(100)) | ||
.Open()) | ||
{ | ||
|
||
// then | ||
Assert.True(jobWorker.IsOpen()); | ||
|
||
signal.WaitOne(); | ||
} | ||
|
||
var actualRequest = TestService.Requests[0]; | ||
Assert.AreEqual(expectedRequest, actualRequest); | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.