-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2841 from Azure/nytian/merge-dev-to-v3
Merge Branch dev to Branch v3.x
- Loading branch information
Showing
10 changed files
with
107 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Runtime.CompilerServices; | ||
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions; | ||
|
||
// TODO: Find a way to generate this dynamically at build-time | ||
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.DurableTask", "2.13.3")] | ||
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.DurableTask", "2.13.4")] | ||
[assembly: InternalsVisibleTo("Worker.Extensions.DurableTask.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cd1dabd5a893b40e75dc901fe7293db4a3caf9cd4d3e3ed6178d49cd476969abe74a9e0b7f4a0bb15edca48758155d35a4f05e6e852fff1b319d103b39ba04acbadd278c2753627c95e1f6f6582425374b92f51cca3deb0d2aab9de3ecda7753900a31f70a236f163006beefffe282888f85e3c76d1205ec7dfef7fa472a17b1")] |
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
57 changes: 57 additions & 0 deletions
57
test/Worker.Extensions.DurableTask.Tests/FunctionsDurableTaskClientTests.cs
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,57 @@ | ||
using Microsoft.DurableTask.Client; | ||
using Microsoft.DurableTask.Client.Grpc; | ||
using Moq; | ||
|
||
namespace Microsoft.Azure.Functions.Worker.Tests | ||
{ | ||
/// <summary> | ||
/// Unit tests for <see cref="FunctionsDurableTaskClient />. | ||
/// </summary> | ||
public class FunctionsDurableTaskClientTests | ||
{ | ||
private FunctionsDurableTaskClient GetTestFunctionsDurableTaskClient() | ||
{ | ||
// construct mock client | ||
|
||
// The DurableTaskClient demands a string parameter in it's constructor, so we pass it in | ||
string clientName = string.Empty; | ||
Mock<DurableTaskClient> durableClientMock = new(clientName); | ||
|
||
Task completedTask = Task.CompletedTask; | ||
durableClientMock.Setup(x => x.TerminateInstanceAsync( | ||
It.IsAny<string>(), It.IsAny<TerminateInstanceOptions>(), It.IsAny<CancellationToken>())).Returns(completedTask); | ||
|
||
DurableTaskClient durableClient = durableClientMock.Object; | ||
FunctionsDurableTaskClient client = new FunctionsDurableTaskClient(durableClient, queryString: null); | ||
return client; | ||
} | ||
|
||
/// <summary> | ||
/// Test that the `TerminateInstnaceAsync` can be invoked without exceptions. | ||
/// Exceptions are a risk since we inherit from an abstract class where default implementations are not provided. | ||
/// </summary> | ||
[Fact] | ||
public async void TerminateDoesNotThrow() | ||
{ | ||
FunctionsDurableTaskClient client = GetTestFunctionsDurableTaskClient(); | ||
|
||
string instanceId = string.Empty; | ||
object output = string.Empty; | ||
TerminateInstanceOptions options = new TerminateInstanceOptions(); | ||
CancellationToken token = CancellationToken.None; | ||
|
||
// call terminate API with every possible parameter combination | ||
// if we don't encounter any unimplemented exceptions from the abstract class, | ||
// then the test passes | ||
|
||
await client.TerminateInstanceAsync(instanceId, token); | ||
|
||
await client.TerminateInstanceAsync(instanceId, output); | ||
await client.TerminateInstanceAsync(instanceId, output, token); | ||
|
||
await client.TerminateInstanceAsync(instanceId); | ||
await client.TerminateInstanceAsync(instanceId, options); | ||
await client.TerminateInstanceAsync(instanceId, options, token); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test/Worker.Extensions.DurableTask.Tests/Worker.Extensions.DurableTask.Tests.csproj
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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
|
||
<!-- Sign assembly so it can reference internal components of the Worker Extension package --> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.5.3" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" /> | ||
<PackageReference Include="Moq" Version="4.7.145" /> | ||
<ProjectReference Include="..\..\src\Worker.Extensions.DurableTask\Worker.Extensions.DurableTask.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
</Project> |