Skip to content

Commit

Permalink
refactor: migrate tests to NUnit 4.x api
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisKujawa committed May 28, 2024
1 parent 2194968 commit 734468c
Show file tree
Hide file tree
Showing 31 changed files with 347 additions and 345 deletions.
16 changes: 8 additions & 8 deletions Client.IntegrationTests/BrokerTopologyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ public async Task RequestTopology()
Console.WriteLine(topology);

var gatewayVersion = topology.GatewayVersion;
Assert.AreEqual(ZeebeIntegrationTestHelper.LatestVersion, gatewayVersion);
Assert.Equals(ZeebeIntegrationTestHelper.LatestVersion, gatewayVersion);

var topologyBrokers = topology.Brokers;
Assert.AreEqual(1, topologyBrokers.Count);
Assert.Equals(1, topologyBrokers.Count);

var topologyBroker = topologyBrokers[0];
Assert.AreEqual(0, topologyBroker.NodeId);
Assert.Equals(0, topologyBroker.NodeId);

// assert host and port ?!
// Assert.AreEqual(container.GetMappedPort(26500), topologyBroker.Port);
// Assert.Equals(container.GetMappedPort(26500), topologyBroker.Port);

var partitions = topologyBroker.Partitions;
Assert.AreEqual(1, partitions.Count);
Assert.Equals(1, partitions.Count);

var partitionInfo = partitions[0];
Assert.AreEqual(PartitionBrokerRole.LEADER, partitionInfo.Role);
Assert.AreEqual(true, partitionInfo.IsLeader);
Assert.AreEqual(1, partitionInfo.PartitionId);
Assert.Equals(PartitionBrokerRole.LEADER, partitionInfo.Role);
Assert.Equals(true, partitionInfo.IsLeader);
Assert.Equals(1, partitionInfo.PartitionId);
}
}
}
10 changes: 5 additions & 5 deletions Client.IntegrationTests/EvaluateDecisionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public async Task ShouldEvaluateDecision()
.Send();

// then
Assert.AreEqual(evaluateDecisionResponse.DecisionVersion, 1);
Assert.AreEqual(decisionKey, evaluateDecisionResponse.DecisionKey);
Assert.AreEqual("dish", evaluateDecisionResponse.DecisionId);
Assert.Greater(evaluateDecisionResponse.DecisionKey, 1);
Assert.Equals(evaluateDecisionResponse.DecisionVersion, 1);
Assert.Equals(decisionKey, evaluateDecisionResponse.DecisionKey);
Assert.Equals("dish", evaluateDecisionResponse.DecisionId);
Assert.That(evaluateDecisionResponse.DecisionKey, Is.GreaterThan(1));
// right now it seems the DMN engine returns an double quated string
Assert.AreEqual("\"Stew\"", evaluateDecisionResponse.DecisionOutput);
Assert.Equals("\"Stew\"", evaluateDecisionResponse.DecisionOutput);
}
}
4 changes: 2 additions & 2 deletions Client.IntegrationTests/JobWorkerMultiPartitionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ await zeebeClient.NewCreateProcessInstanceCommand()
}
}

Assert.AreEqual(3, handledJobs.Count);
Assert.Equals(3, handledJobs.Count);
}

[Test]
Expand All @@ -93,7 +93,7 @@ await zeebeClient.NewCreateProcessInstanceCommand()
.Timeout(TimeSpan.FromHours(10))
.Send();

Assert.AreEqual(3, activateJobsResponse.Jobs.Count);
Assert.Equals(3, activateJobsResponse.Jobs.Count);
}
}
}
20 changes: 10 additions & 10 deletions Client.IntegrationTests/JobWorkerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public async Task ShouldCompleteProcess()
.Send();

// then process was completed
Assert.AreEqual(1, handledJobs.Count, "Jobs handled");
Assert.Equals(handledJobs.Count, 1);

Assert.AreEqual(processInstance.Version, 1);
Assert.AreEqual(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.AreEqual("oneTaskProcess", processInstance.BpmnProcessId);
Assert.Greater(processInstance.ProcessInstanceKey, 1);
Assert.Equals(processInstance.Version, 1);
Assert.Equals(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.Equals("oneTaskProcess", processInstance.BpmnProcessId);
Assert.That(processInstance.ProcessInstanceKey, Is.GreaterThan(1));
}
}

Expand Down Expand Up @@ -93,12 +93,12 @@ public async Task ShouldCompleteProcessWithJobAutoCompletion()
.Send();

// then process was completed
Assert.AreEqual(1, handledJobs.Count);
Assert.Equals(1, handledJobs.Count);

Assert.AreEqual(processInstance.Version, 1);
Assert.AreEqual(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.AreEqual("oneTaskProcess", processInstance.BpmnProcessId);
Assert.Greater(processInstance.ProcessInstanceKey, 1);
Assert.Equals(processInstance.Version, 1);
Assert.Equals(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.Equals("oneTaskProcess", processInstance.BpmnProcessId);
Assert.That(processInstance.ProcessInstanceKey, Is.GreaterThan(1));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Client.IntegrationTests/OAuthIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public async Task ShouldSendRequestAndNotFailingWithAuthenticatedClient()
var authenticatedZeebeClient = testHelper.CreateAuthenticatedZeebeClient();
var topology = await authenticatedZeebeClient.TopologyRequest().Send();
var gatewayVersion = topology.GatewayVersion;
Assert.AreEqual(ZeebeIntegrationTestHelper.LatestVersion, gatewayVersion);
Assert.Equals(ZeebeIntegrationTestHelper.LatestVersion, gatewayVersion);

var topologyBrokers = topology.Brokers;
Assert.AreEqual(1, topologyBrokers.Count);
Assert.Equals(1, topologyBrokers.Count);

var topologyBroker = topologyBrokers[0];
Assert.AreEqual(0, topologyBroker.NodeId);
Assert.Equals(0, topologyBroker.NodeId);
}

[Test]
Expand Down
40 changes: 20 additions & 20 deletions Client.IntegrationTests/ProcessInstanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public async Task ShouldCreateProcessInstance()
.Send();

// then
Assert.AreEqual(processInstance.Version, 1);
Assert.AreEqual(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.AreEqual("oneTaskProcess", processInstance.BpmnProcessId);
Assert.Greater(processInstance.ProcessInstanceKey, 1);
Assert.Equals(processInstance.Version, 1);
Assert.Equals(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.Equals("oneTaskProcess", processInstance.BpmnProcessId);
Assert.That(processInstance.ProcessInstanceKey, Is.GreaterThan(1));
}

[Test]
Expand All @@ -67,7 +67,7 @@ public void ShouldNotCreateProcessInstanceWithoutDeployment()

// then
var rpcException = (RpcException) aggregateException.InnerExceptions[0];
Assert.AreEqual(StatusCode.NotFound, rpcException.Status.StatusCode);
Assert.Equals(StatusCode.NotFound, rpcException.Status.StatusCode);
}

[Test]
Expand All @@ -88,14 +88,14 @@ public async Task ShouldGetResultAfterCreateProcessInstance()
.Send();

// then
Assert.AreEqual(processInstance.Version, 1);
Assert.AreEqual(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.AreEqual("simpleProcess", processInstance.BpmnProcessId);
Assert.Greater(processInstance.ProcessInstanceKey, 1);
Assert.Equals(processInstance.Version, 1);
Assert.Equals(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.Equals("simpleProcess", processInstance.BpmnProcessId);
Assert.That(processInstance.ProcessInstanceKey, Is.GreaterThan(1));

var expectedJson = JObject.Parse(ProcessInstanceVariables);
var actualJson = JObject.Parse(processInstance.Variables);
Assert.IsTrue(JToken.DeepEquals(expectedJson, actualJson));
Assert.That(JToken.DeepEquals(expectedJson, actualJson), Is.True);
}

[Test]
Expand All @@ -117,14 +117,14 @@ public async Task ShouldFetchVariablesOfResult()
.Send();

// then
Assert.AreEqual(processInstance.Version, 1);
Assert.AreEqual(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.AreEqual("simpleProcess", processInstance.BpmnProcessId);
Assert.Greater(processInstance.ProcessInstanceKey, 1);
Assert.Equals(processInstance.Version, 1);
Assert.Equals(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.Equals("simpleProcess", processInstance.BpmnProcessId);
Assert.That(processInstance.ProcessInstanceKey, Is.GreaterThan(1));

var expectedJson = new JObject { { "b", true } };
var actualJson = JObject.Parse(processInstance.Variables);
Assert.IsTrue(JToken.DeepEquals(expectedJson, actualJson));
Assert.That(JToken.DeepEquals(expectedJson, actualJson), Is.True);
}

[Test]
Expand All @@ -146,14 +146,14 @@ public async Task ShouldFetchNoVariablesOfResult()
.Send();

// then
Assert.AreEqual(processInstance.Version, 1);
Assert.AreEqual(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.AreEqual("simpleProcess", processInstance.BpmnProcessId);
Assert.Greater(processInstance.ProcessInstanceKey, 1);
Assert.Equals(processInstance.Version, 1);
Assert.Equals(processDefinitionKey, processInstance.ProcessDefinitionKey);
Assert.Equals("simpleProcess", processInstance.BpmnProcessId);
Assert.That(processInstance.ProcessInstanceKey, Is.GreaterThan(1));

var expectedJson = new JObject();
var actualJson = JObject.Parse(processInstance.Variables);
Assert.IsTrue(JToken.DeepEquals(expectedJson, actualJson));
Assert.That(JToken.DeepEquals(expectedJson, actualJson), Is.True);
}
}
}
13 changes: 7 additions & 6 deletions Client.IntegrationTests/ProcessTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ public async Task DeployProcessTest()
.Send();

// then
Assert.Greater(deployResponse.Key, 0);
Assert.That(deployResponse.Key, Is.GreaterThan(0));

var deployedProcesses = deployResponse.Processes;
Assert.AreEqual(1, deployedProcesses.Count);
Assert.Equals(1, deployedProcesses.Count);

Assert.AreEqual(1, deployedProcesses[0].Version);
Assert.Greater(deployedProcesses[0].ProcessDefinitionKey, 1);
Assert.AreEqual("simpleProcess", deployedProcesses[0].BpmnProcessId);
Assert.AreEqual(DemoProcessPath, deployedProcesses[0].ResourceName);
Assert.Equals(1, deployedProcesses[0].Version);
Assert.That(deployedProcesses[0].ProcessDefinitionKey, Is.GreaterThan(1));

Assert.Equals("simpleProcess", deployedProcesses[0].BpmnProcessId);
Assert.Equals(DemoProcessPath, deployedProcesses[0].ResourceName);
}
}
}
20 changes: 10 additions & 10 deletions Client.UnitTests/ActivateJobTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public async Task ShouldSendRequestReceiveResponseAsExpected()

// then
var actualRequest = TestService.Requests[typeof(ActivateJobsRequest)][0];
Assert.AreEqual(expectedRequest, actualRequest);
Assert.Equals(expectedRequest, actualRequest);

var receivedJobs = response.Jobs;
Assert.AreEqual(receivedJobs.Count, 3);
Assert.Equals(receivedJobs.Count, 3);

AssertJob(receivedJobs[0], 1);
AssertJob(receivedJobs[1], 2);
Expand All @@ -65,7 +65,7 @@ public void ShouldTimeoutRequest()
var rpcException = (RpcException)aggregateException.InnerExceptions[0];

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

[Test]
Expand All @@ -85,7 +85,7 @@ public void ShouldCancelRequest()
var rpcException = (RpcException)aggregateException.InnerExceptions[0];

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

[Test]
Expand Down Expand Up @@ -116,10 +116,10 @@ public async Task ShouldSendRequestWithFetchVariablesReceiveResponseAsExpected()

// then
var actualRequest = TestService.Requests[typeof(ActivateJobsRequest)][0];
Assert.AreEqual(expectedRequest, actualRequest);
Assert.Equals(expectedRequest, actualRequest);

var receivedJobs = response.Jobs;
Assert.AreEqual(receivedJobs.Count, 3);
Assert.Equals(receivedJobs.Count, 3);

AssertJob(receivedJobs[0], 1);
AssertJob(receivedJobs[1], 2);
Expand Down Expand Up @@ -154,10 +154,10 @@ public async Task ShouldSendRequestWithFetchVariablesListReceiveResponseAsExpect

// then
var actualRequest = TestService.Requests[typeof(ActivateJobsRequest)][0];
Assert.AreEqual(expectedRequest, actualRequest);
Assert.Equals(expectedRequest, actualRequest);

var receivedJobs = response.Jobs;
Assert.AreEqual(receivedJobs.Count, 3);
Assert.Equals(receivedJobs.Count, 3);

AssertJob(receivedJobs[0], 1);
AssertJob(receivedJobs[1], 2);
Expand Down Expand Up @@ -193,10 +193,10 @@ public async Task ShouldSendRequestWithTenantIdsListReceiveResponseAsExpected()

// then
var actualRequest = TestService.Requests[typeof(ActivateJobsRequest)][0];
Assert.AreEqual(expectedRequest, actualRequest);
Assert.Equals(expectedRequest, actualRequest);

var receivedJobs = response.Jobs;
Assert.AreEqual(receivedJobs.Count, 3);
Assert.Equals(receivedJobs.Count, 3);

AssertJob(receivedJobs[0], 1);
AssertJob(receivedJobs[1], 2);
Expand Down
6 changes: 3 additions & 3 deletions Client.UnitTests/CancelProcessInstanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task ShouldSendRequestAsExpected()

// then
var request = TestService.Requests[typeof(CancelProcessInstanceRequest)][0];
Assert.AreEqual(expected, request);
Assert.Equals(expected, request);
}

[Test]
Expand All @@ -39,7 +39,7 @@ public void ShouldTimeoutRequest()
var rpcException = (RpcException)aggregateException.InnerExceptions[0];

// then
Assert.AreEqual(StatusCode.DeadlineExceeded, rpcException.Status.StatusCode);
Assert.Equals(StatusCode.DeadlineExceeded, rpcException.Status.StatusCode);
}

[Test]
Expand All @@ -54,7 +54,7 @@ public void ShouldCancelRequest()
var rpcException = (RpcException)aggregateException.InnerExceptions[0];

// then
Assert.AreEqual(StatusCode.Cancelled, rpcException.Status.StatusCode);
Assert.Equals(StatusCode.Cancelled, rpcException.Status.StatusCode);
}
}
}
8 changes: 4 additions & 4 deletions Client.UnitTests/CompleteJobTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task ShouldSendRequestAsExpected()
// then
var actualRequest = TestService.Requests[typeof(CompleteJobRequest)][0];

Assert.AreEqual(expectedRequest, actualRequest);
Assert.Equals(expectedRequest, actualRequest);
}

[Test]
Expand All @@ -59,7 +59,7 @@ public void ShouldTimeoutRequest()
var rpcException = (RpcException) aggregateException.InnerExceptions[0];

// then
Assert.AreEqual(StatusCode.DeadlineExceeded, rpcException.Status.StatusCode);
Assert.Equals(StatusCode.DeadlineExceeded, rpcException.Status.StatusCode);
}

[Test]
Expand All @@ -75,7 +75,7 @@ public void ShouldCancelRequest()
var rpcException = (RpcException)aggregateException.InnerExceptions[0];

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

[Test]
Expand All @@ -100,7 +100,7 @@ public async Task ShouldUseActivatedJobToComplete()
// then
var actualRequest = TestService.Requests[typeof(CompleteJobRequest)][0];

Assert.AreEqual(expectedRequest, actualRequest);
Assert.Equals(expectedRequest, actualRequest);
}
}
}
Loading

0 comments on commit 734468c

Please sign in to comment.