diff --git a/src/azure/src/azure/ServiceBus/TaskQueue/TaskCoordinator.cs b/src/azure/src/azure/ServiceBus/TaskQueue/TaskCoordinator.cs index 253d223..fe6ca33 100644 --- a/src/azure/src/azure/ServiceBus/TaskQueue/TaskCoordinator.cs +++ b/src/azure/src/azure/ServiceBus/TaskQueue/TaskCoordinator.cs @@ -14,6 +14,14 @@ public class TaskCoordinator : ITaskCoordinator { private readonly ILogger _log; private readonly ITaskHandlerResolver _taskHandlerResolver; + /// + /// Initializes a new instance of the class. + /// This constructor is intended for mocking purposes. + /// + protected TaskCoordinator() + { + } + /// /// Initializes a new instance of the class. /// @@ -25,7 +33,7 @@ public TaskCoordinator(ITaskHandlerResolver taskHandlerResolver, ILogger - public Task ProcessQueueMessageAsync(string message, CancellationToken cancellationToken = default) { + public virtual Task ProcessQueueMessageAsync(string message, CancellationToken cancellationToken = default) { var taskRequest = DeserializeTaskRequest(message); return ProcessTaskAsync(taskRequest, cancellationToken); } @@ -36,7 +44,7 @@ public Task ProcessQueueMessageAsync(string message, CancellationToken cancellat /// The to process. /// A that can be used to cancel the operation. /// A that represents the asynchronous operation. - public async Task ProcessTaskAsync(TaskRequest taskRequest, CancellationToken cancellationToken = default) { + public virtual async Task ProcessTaskAsync(TaskRequest taskRequest, CancellationToken cancellationToken = default) { var taskRequestType = taskRequest.GetType(); var taskRequestTrackingId = taskRequest.TrackingId.ToString("D"); _log.LogInformation("Received task {TaskRequestTrackingId} of type {TaskRequestType}", diff --git a/src/azure/src/azure/ServiceBus/TaskQueue/TaskRequestQueue.cs b/src/azure/src/azure/ServiceBus/TaskQueue/TaskRequestQueue.cs index add0801..544cf4a 100644 --- a/src/azure/src/azure/ServiceBus/TaskQueue/TaskRequestQueue.cs +++ b/src/azure/src/azure/ServiceBus/TaskQueue/TaskRequestQueue.cs @@ -37,14 +37,14 @@ public TaskRequestQueue(ServiceBusClient queueClient, string taskQueueName) { } /// - public Task AddTaskAsync(TaskRequest request, CancellationToken cancellationToken = default) { + public virtual Task AddTaskAsync(TaskRequest request, CancellationToken cancellationToken = default) { var serializedRequest = request.ToJson(); var message = new ServiceBusMessage(Encoding.UTF8.GetBytes(serializedRequest)); return GetQueueSender().SendMessageAsync(message, cancellationToken); } /// - public Task ScheduleTaskAsync(TaskRequest request, DateTimeOffset scheduledMessageEnqueueTime, CancellationToken cancellationToken = default) { + public virtual Task ScheduleTaskAsync(TaskRequest request, DateTimeOffset scheduledMessageEnqueueTime, CancellationToken cancellationToken = default) { var serializedRequest = request.ToJson(); var message = new ServiceBusMessage(Encoding.UTF8.GetBytes(serializedRequest)); return GetQueueSender().ScheduleMessageAsync(message, scheduledMessageEnqueueTime, cancellationToken);