Skip to content

Commit

Permalink
Merge pull request #4 from GodelTech/feature/add-interface
Browse files Browse the repository at this point in the history
add interface
  • Loading branch information
rodchenkov authored Mar 28, 2021
2 parents b405ed9 + 1b520b3 commit 7d85b33
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace GodelTech.Messaging.AzureServiceBus
/// <summary>
/// Azure Service Bus sender
/// </summary>
public class AzureServiceBusSender
public class AzureServiceBusSender : IAzureServiceBusSender
{
private readonly ServiceBusClient _serviceBusClient;
private readonly AzureServiceBusOptions _azureServiceBusOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static IServiceCollection AddAzureServiceBusSender(
services.Configure(optionsAction);

// AzureServiceBusSender
services.AddTransient<AzureServiceBusSender>();
services.AddTransient<IAzureServiceBusSender, AzureServiceBusSender>();

return services;
}
Expand Down
22 changes: 22 additions & 0 deletions src/GodelTech.Messaging.AzureServiceBus/IAzureServiceBusSender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Threading.Tasks;

namespace GodelTech.Messaging.AzureServiceBus
{
/// <summary>
/// Interface of Azure Service Bus sender
/// </summary>
public interface IAzureServiceBusSender
{
/// <summary>
/// Asynchronously sends TModel object as JSON to Azure Service Bus queue.
/// Queue is select by key from options.
/// </summary>
/// <typeparam name="TModel">The type of the T model.</typeparam>
/// <param name="queueKey">Queue key.</param>
/// <param name="model">The model.</param>
/// <exception cref="ArgumentOutOfRangeException">No queue found with provided key.</exception>
public Task SendAsync<TModel>(string queueKey, TModel model)
where TModel : class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void AddAzureServiceBusSender_Success()
Assert.NotNull(resultOptionsAction.Value);
Assert.Equal(queues, resultOptionsAction.Value.Queues);

var resultAzureServiceBusSender = provider.GetRequiredService<AzureServiceBusSender>();
var resultAzureServiceBusSender = provider.GetRequiredService<IAzureServiceBusSender>();
Assert.NotNull(resultAzureServiceBusSender);
Assert.IsType<AzureServiceBusSender>(resultAzureServiceBusSender);
}
}
}

0 comments on commit 7d85b33

Please sign in to comment.