-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
174 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
|
||
namespace Microsoft.DurableTask.Tests; | ||
|
||
public class ActivityRequestTests | ||
{ | ||
[Theory] | ||
[InlineData(null)] | ||
[InlineData(10)] | ||
public void Create_Success(int? input) | ||
{ | ||
TaskName name = "Test"; | ||
IActivityRequest request = ActivityRequest.Create(name, input); | ||
|
||
request.GetInput().Should().Be(input); | ||
request.GetTaskName().Should().Be(name); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("input")] | ||
public void Create_OfT_Success(string input) | ||
{ | ||
TaskName name = "Test"; | ||
IActivityRequest<int> request = ActivityRequest.Create<int>(name, input); | ||
|
||
request.GetInput().Should().Be(input); | ||
request.GetTaskName().Should().Be(name); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("input")] | ||
public async Task RunRequest_Success(string input) | ||
{ | ||
TaskName name = "Test"; | ||
IActivityRequest request = ActivityRequest.Create(name, input); | ||
Mock<TaskOrchestrationContext> context = new(MockBehavior.Strict); | ||
context.Setup(m => m.CallActivityAsync(name, input, null)).Returns(Task.CompletedTask); | ||
|
||
await context.Object.RunAsync(request); | ||
|
||
context.Verify(m => m.CallActivityAsync(name, input, null), Times.Once); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("input")] | ||
public async Task RunRequest_OfT_Success(string input) | ||
{ | ||
TaskName name = "Test"; | ||
IActivityRequest<int> request = ActivityRequest.Create<int>(name, input); | ||
Mock<TaskOrchestrationContext> context = new(MockBehavior.Strict); | ||
context.Setup(m => m.CallActivityAsync<int>(name, input, null)).Returns(Task.FromResult(0)); | ||
|
||
await context.Object.RunAsync(request); | ||
|
||
context.Verify(m => m.CallActivityAsync<int>(name, input, null), Times.Once); | ||
} | ||
} |
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 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
|
||
namespace Microsoft.DurableTask.Tests; | ||
|
||
public class OrchestrationRequestTests | ||
{ | ||
[Theory] | ||
[InlineData(null)] | ||
[InlineData(10)] | ||
public void Create_Success(int? input) | ||
{ | ||
TaskName name = "Test"; | ||
IOrchestrationRequest request = OrchestrationRequest.Create(name, input); | ||
|
||
request.GetInput().Should().Be(input); | ||
request.GetTaskName().Should().Be(name); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("input")] | ||
public void Create_OfT_Success(string input) | ||
{ | ||
TaskName name = "Test"; | ||
IOrchestrationRequest<int> request = OrchestrationRequest.Create<int>(name, input); | ||
|
||
request.GetInput().Should().Be(input); | ||
request.GetTaskName().Should().Be(name); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("input")] | ||
public async Task RunRequest_Success(string input) | ||
{ | ||
TaskName name = "Test"; | ||
IOrchestrationRequest request = OrchestrationRequest.Create(name, input); | ||
Mock<TaskOrchestrationContext> context = new(MockBehavior.Strict); | ||
context.Setup(m => m.CallSubOrchestratorAsync(name, input, null)).Returns(Task.CompletedTask); | ||
|
||
await context.Object.RunAsync(request); | ||
|
||
context.Verify(m => m.CallSubOrchestratorAsync(name, input, null), Times.Once); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("input")] | ||
public async Task RunRequest_OfT_Success(string input) | ||
{ | ||
TaskName name = "Test"; | ||
IOrchestrationRequest<int> request = OrchestrationRequest.Create<int>(name, input); | ||
Mock<TaskOrchestrationContext> context = new(MockBehavior.Strict); | ||
context.Setup(m => m.CallSubOrchestratorAsync<int>(name, input, null)).Returns(Task.FromResult(0)); | ||
|
||
await context.Object.RunAsync(request); | ||
|
||
context.Verify(m => m.CallSubOrchestratorAsync<int>(name, input, null), Times.Once); | ||
} | ||
} |