forked from dapr/dotnet-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workflow unit testing changes for 1.10 release (dapr#1038)
* Update DurableTask SDK dependency to get ARM64 compatibility (dapr#1024) * Update DurableTask SDK dependency to get ARM64 compatibility Signed-off-by: Chris Gillum <cgillum@microsoft.com> * Fix issue with gRPC address override behavior Signed-off-by: Chris Gillum <cgillum@microsoft.com> * Workflow SDK changes to enable unit testing Signed-off-by: Chris Gillum <cgillum@microsoft.com> --------- Signed-off-by: Chris Gillum <cgillum@microsoft.com>
- Loading branch information
Showing
3 changed files
with
120 additions
and
57 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,98 @@ | ||
// ------------------------------------------------------------------------ | ||
// Copyright 2023 The Dapr Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ------------------------------------------------------------------------ | ||
|
||
namespace Dapr.Workflow | ||
{ | ||
using System; | ||
using Microsoft.DurableTask; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
class DaprWorkflowContext : WorkflowContext | ||
{ | ||
readonly TaskOrchestrationContext innerContext; | ||
|
||
internal DaprWorkflowContext(TaskOrchestrationContext innerContext) | ||
{ | ||
this.innerContext = innerContext ?? throw new ArgumentNullException(nameof(innerContext)); | ||
} | ||
|
||
public override string Name => this.innerContext.Name; | ||
|
||
public override string InstanceId => this.innerContext.InstanceId; | ||
|
||
public override DateTime CurrentUtcDateTime => this.innerContext.CurrentUtcDateTime; | ||
|
||
public override bool IsReplaying => this.innerContext.IsReplaying; | ||
|
||
public override Task CallActivityAsync(string name, object? input = null, TaskOptions? options = null) | ||
{ | ||
return this.innerContext.CallActivityAsync(name, input, options); | ||
} | ||
|
||
public override Task<T> CallActivityAsync<T>(string name, object? input = null, TaskOptions? options = null) | ||
{ | ||
return this.innerContext.CallActivityAsync<T>(name, input, options); | ||
} | ||
|
||
public override Task CreateTimer(TimeSpan delay, CancellationToken cancellationToken = default) | ||
{ | ||
return this.innerContext.CreateTimer(delay, cancellationToken); | ||
} | ||
|
||
public override Task CreateTimer(DateTime fireAt, CancellationToken cancellationToken) | ||
{ | ||
return this.innerContext.CreateTimer(fireAt, cancellationToken); | ||
} | ||
|
||
public override Task<T> WaitForExternalEventAsync<T>(string eventName, CancellationToken cancellationToken = default) | ||
{ | ||
return this.innerContext.WaitForExternalEvent<T>(eventName, cancellationToken); | ||
} | ||
|
||
public override Task<T> WaitForExternalEventAsync<T>(string eventName, TimeSpan timeout) | ||
{ | ||
return this.innerContext.WaitForExternalEvent<T>(eventName, timeout); | ||
} | ||
|
||
public override void SendEvent(string instanceId, string eventName, object payload) | ||
{ | ||
this.innerContext.SendEvent(instanceId, eventName, payload); | ||
} | ||
|
||
public override void SetCustomStatus(object? customStatus) | ||
{ | ||
this.innerContext.SetCustomStatus(customStatus); | ||
} | ||
|
||
public override Task<TResult> CallChildWorkflowAsync<TResult>(string workflowName, object? input = null, TaskOptions? options = null) | ||
{ | ||
return this.innerContext.CallSubOrchestratorAsync<TResult>(workflowName, input, options); | ||
} | ||
|
||
public override Task CallChildWorkflowAsync(string workflowName, object? input = null, TaskOptions? options = null) | ||
{ | ||
return this.innerContext.CallSubOrchestratorAsync(workflowName, input, options); | ||
} | ||
|
||
public override void ContinueAsNew(object? newInput = null, bool preserveUnprocessedEvents = true) | ||
{ | ||
this.innerContext.ContinueAsNew(newInput!, preserveUnprocessedEvents); | ||
} | ||
|
||
public override Guid NewGuid() | ||
{ | ||
return this.innerContext.NewGuid(); | ||
} | ||
} | ||
} |
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