Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide the ability to Mock WorkflowActivityContext #1358

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions all.sln
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dapr.E2E.Test.Actors.Genera
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cryptography", "examples\Client\Cryptography\Cryptography.csproj", "{C74FBA78-13E8-407F-A173-4555AEE41FF3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dapr.Workflow.Test", "test\Dapr.Workflow.Test\Dapr.Workflow.Test.csproj", "{7CA93D67-C551-430E-AA2C-BC64B77F7908}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapr.Protos", "src\Dapr.Protos\Dapr.Protos.csproj", "{DFBABB04-50E9-42F6-B470-310E1B545638}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapr.Common", "src\Dapr.Common\Dapr.Common.csproj", "{B445B19C-A925-4873-8CB7-8317898B6970}"
Expand Down Expand Up @@ -153,8 +155,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Jobs", "Jobs", "{D9697361-2
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JobsSample", "examples\Jobs\JobsSample\JobsSample.csproj", "{9CAF360E-5AD3-4C4F-89A0-327EEB70D673}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dapr.Workflow.Test", "test\Dapr.Workflow.Test\Dapr.Workflow.Test.csproj", "{E90114C6-86FC-43B8-AE5C-D9273CF21FE4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -327,6 +327,10 @@ Global
{C74FBA78-13E8-407F-A173-4555AEE41FF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C74FBA78-13E8-407F-A173-4555AEE41FF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C74FBA78-13E8-407F-A173-4555AEE41FF3}.Release|Any CPU.Build.0 = Release|Any CPU
{7CA93D67-C551-430E-AA2C-BC64B77F7908}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CA93D67-C551-430E-AA2C-BC64B77F7908}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CA93D67-C551-430E-AA2C-BC64B77F7908}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CA93D67-C551-430E-AA2C-BC64B77F7908}.Release|Any CPU.Build.0 = Release|Any CPU
{DFBABB04-50E9-42F6-B470-310E1B545638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DFBABB04-50E9-42F6-B470-310E1B545638}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DFBABB04-50E9-42F6-B470-310E1B545638}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -399,10 +403,6 @@ Global
{9CAF360E-5AD3-4C4F-89A0-327EEB70D673}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CAF360E-5AD3-4C4F-89A0-327EEB70D673}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CAF360E-5AD3-4C4F-89A0-327EEB70D673}.Release|Any CPU.Build.0 = Release|Any CPU
{E90114C6-86FC-43B8-AE5C-D9273CF21FE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E90114C6-86FC-43B8-AE5C-D9273CF21FE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E90114C6-86FC-43B8-AE5C-D9273CF21FE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E90114C6-86FC-43B8-AE5C-D9273CF21FE4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -456,6 +456,7 @@ Global
{AF89083D-4715-42E6-93E9-38497D12A8A6} = {DD020B34-460F-455F-8D17-CF4A949F100B}
{B5CDB0DC-B26D-48F1-B934-FE5C1C991940} = {DD020B34-460F-455F-8D17-CF4A949F100B}
{C74FBA78-13E8-407F-A173-4555AEE41FF3} = {A7F41094-8648-446B-AECD-DCC2CC871F73}
{7CA93D67-C551-430E-AA2C-BC64B77F7908} = {DD020B34-460F-455F-8D17-CF4A949F100B}
{DFBABB04-50E9-42F6-B470-310E1B545638} = {27C5D71D-0721-4221-9286-B94AB07B58CF}
{B445B19C-A925-4873-8CB7-8317898B6970} = {27C5D71D-0721-4221-9286-B94AB07B58CF}
{CDB47863-BEBD-4841-A807-46D868962521} = {DD020B34-460F-455F-8D17-CF4A949F100B}
Expand All @@ -476,7 +477,6 @@ Global
{BF9828E9-5597-4D42-AA6E-6E6C12214204} = {DD020B34-460F-455F-8D17-CF4A949F100B}
{D9697361-232F-465D-A136-4561E0E88488} = {D687DDC4-66C5-4667-9E3A-FD8B78ECAA78}
{9CAF360E-5AD3-4C4F-89A0-327EEB70D673} = {D9697361-232F-465D-A136-4561E0E88488}
{E90114C6-86FC-43B8-AE5C-D9273CF21FE4} = {DD020B34-460F-455F-8D17-CF4A949F100B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {65220BF2-EAE1-4CB2-AA58-EBE80768CB40}
Expand Down
37 changes: 37 additions & 0 deletions src/Dapr.Workflow/DaprWorkflowActivityContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ------------------------------------------------------------------------
// Copyright 2022 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;

/// <summary>
/// Defines properties and methods for task activity context objects.
/// </summary>
public class DaprWorkflowActivityContext : WorkflowActivityContext
{
readonly TaskActivityContext innerContext;

internal DaprWorkflowActivityContext(TaskActivityContext innerContext)
{
this.innerContext = innerContext ?? throw new ArgumentNullException(nameof(innerContext));
}

/// <inheritdoc/>
public override TaskName Name => this.innerContext.Name;

/// <inheritdoc/>
public override string InstanceId => this.innerContext.InstanceId;
}
}
14 changes: 3 additions & 11 deletions src/Dapr.Workflow/WorkflowActivityContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,21 @@

namespace Dapr.Workflow
{
using System;
using Microsoft.DurableTask;

/// <summary>
/// Defines properties and methods for task activity context objects.
/// </summary>
public class WorkflowActivityContext
public abstract class WorkflowActivityContext
{
readonly TaskActivityContext innerContext;

internal WorkflowActivityContext(TaskActivityContext innerContext)
{
this.innerContext = innerContext ?? throw new ArgumentNullException(nameof(innerContext));
}

/// <summary>
/// Gets the name of the activity.
/// </summary>
public TaskName Name => this.innerContext.Name;
public abstract TaskName Name { get; }

/// <summary>
/// Gets the unique ID of the current workflow instance.
/// </summary>
public string InstanceId => this.innerContext.InstanceId;
public abstract string InstanceId { get; }
}
}
4 changes: 2 additions & 2 deletions src/Dapr.Workflow/WorkflowRuntimeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void RegisterActivity<TInput, TOutput>(string name, Func<WorkflowActivity
{
registry.AddActivityFunc<TInput, TOutput>(name, (innerContext, input) =>
{
WorkflowActivityContext activityContext = new(innerContext);
WorkflowActivityContext activityContext = new DaprWorkflowActivityContext(innerContext);
return implementation(activityContext, input);
});
WorkflowLoggingService.LogActivityName(name);
Expand Down Expand Up @@ -183,7 +183,7 @@ public ActivityWrapper(IWorkflowActivity activity)

public Task<object?> RunAsync(TaskActivityContext context, object? input)
{
return this.activity.RunAsync(new WorkflowActivityContext(context), input);
return this.activity.RunAsync(new DaprWorkflowActivityContext(context), input);
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions test/Dapr.Workflow.Test/Dapr.Workflow.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -9,8 +8,15 @@

<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="coverlet.msbuild">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.extensibility.core" />
<PackageReference Include="xunit.runner.visualstudio" />
Expand All @@ -23,5 +29,4 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Dapr.Workflow\Dapr.Workflow.csproj" />
</ItemGroup>

</Project>
51 changes: 51 additions & 0 deletions test/Dapr.Workflow.Test/WorkflowActivityTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ------------------------------------------------------------------------
// Copyright 2021 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.Test
{
using Moq;
using System.Threading.Tasks;
using Xunit;

/// <summary>
/// Contains tests for WorkflowActivityContext.
/// </summary>
public class WorkflowActivityTest
{
private IWorkflowActivity workflowActivity;

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 25 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Non-nullable field 'workflowActivity' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

private Mock<WorkflowActivityContext> workflowActivityContextMock;

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check failure on line 27 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Non-nullable field 'workflowActivityContextMock' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

[Fact]
public async Task RunAsync_ShouldReturnCorrectContextInstanceId()
{
this.workflowActivity = new TestDaprWorkflowActivity();
this.workflowActivityContextMock = new Mock<WorkflowActivityContext>();

this.workflowActivityContextMock.Setup((x) => x.InstanceId).Returns("instanceId");

string result = (string) await this.workflowActivity.RunAsync(this.workflowActivityContextMock.Object, "input");

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Build

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 9.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 7.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (8.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 8.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (6.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / Test .NET 6.0

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (7.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Converting null literal or possible null value to non-nullable type.

Check failure on line 37 in test/Dapr.Workflow.Test/WorkflowActivityTest.cs

View workflow job for this annotation

GitHub Actions / run integration tests (9.0)

Converting null literal or possible null value to non-nullable type.

Assert.Equal("instanceId", result);
}


public class TestDaprWorkflowActivity : WorkflowActivity<string, string>
{
public override Task<string> RunAsync(WorkflowActivityContext context, string input)
{
return Task.FromResult(context.InstanceId);
}
}
}
}
Loading