Skip to content

Instantly share code, notes, and snippets.

@bryanknox
Last active October 20, 2020 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanknox/dc52b5279708e5563f9997651f076345 to your computer and use it in GitHub Desktop.
Save bryanknox/dc52b5279708e5563f9997651f076345 to your computer and use it in GitHub Desktop.
OBSOLETE: Since Azure Functions Durable Extensions 2.3.0, this technique is no longer needed. Wraps the `DurableEntityProxyExtensions.CreateEntityProxy` extension methods for use in Azure Durable Function Orchestrations unit testing.
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
namespace K0x.DurableFunctionsHelpers
{
/// <summary>
/// Wraps the DurableEntityProxyExtensions.CreateEntityProxy extension methods
/// for use in durable orchestrations that are unit tested.
/// </summary>
/// <remarks>
/// Instead of using the DurableEntityProxyExtensions.CreateEntityProxy<>(..) extension method
/// in an orchestration like:
///
/// var myEntityProxy = context.CreateEntityProxy<IMyEntityProxy>(myEntityId);
///
/// Use dependency injection to inject an instance of class EntityProxyCreator
/// into the orchestration class and then us it to create the entity proxy like:
///
/// var myEntityProxy = _entityProxyCreator.CreateEntityProxy<IMyEntityProxy>(context, myEntityId);
///
/// </remarks>
public class EntityProxyCreator : IEntityProxyCreator
{
public TEntityInterface CreateEntityProxy<TEntityInterface>(
IDurableOrchestrationContext context,
EntityId entityId)
{
// Call the extension method.
return DurableEntityProxyExtensions.CreateEntityProxy<TEntityInterface>(
context,
entityId);
}
}
}
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
namespace K0x.DurableFunctionsHelpers
{
public interface IEntityProxyCreator
{
TEntityInterface CreateEntityProxy<TEntityInterface>(
IDurableOrchestrationContext context,
EntityId entityId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment