From bae2f7f27746bae620a82307c8d9047219a12c5b Mon Sep 17 00:00:00 2001 From: Antonello Provenzano Date: Sat, 16 Mar 2024 21:14:46 +0100 Subject: [PATCH] Updating references and supporting .NET 8.0 --- .../Controllers/SubscriptionController.cs | 12 +++-- samples/WebhookNotifierApp/Program.cs | 4 +- .../WebhookNotifierApp.csproj | 1 + .../WebhookReceiverApp.MinimalApi.csproj | 1 + .../WebhookReceiverApp.csproj | 1 + .../Deveel.Webhooks.DynamicLinq.csproj | 2 +- ...Deveel.Webhooks.Receiver.AspNetCore.csproj | 6 +++ .../Deveel.Webhooks.Sender.csproj | 5 ++ .../Deveel.Webhooks.EntityFramework.csproj | 2 +- .../EntityWebhookDeliveryResultRepository.cs | 2 +- ...EntityWebhookDeliveryResultRepository_T.cs | 8 +-- .../Webhooks/EntityWebhookStorageBuilder.cs | 6 +-- .../EntityWebhookSubscriptionRepository_T.cs | 10 ++-- .../WebhookSubscriptionBuilderExtensions.cs | 12 ++--- .../Deveel.Webhooks.MongoDb.csproj | 2 +- ...ookDeliveryRepositoryRepositoryProvider.cs | 41 +++++++-------- .../MongoDbWebhookDeliveryResultLogger.cs | 6 ++- .../MongoDbWebhookDeliveryResultRepository.cs | 6 ++- ...WebhookDeliveryResultRepositoryProvider.cs | 21 ++++---- ...ongoDbWebhookDeliveryResultRepository_T.cs | 9 ++-- .../Webhooks/MongoDbWebhookStorageBuilder.cs | 14 ++++-- .../MongoDbWebhookSubscriptionRepository.cs | 6 ++- ...DbWebhookSubscriptionRepositoryProvider.cs | 19 ++++--- ...WebhookSubscriptionRepositoryProvider_T.cs | 20 ++++---- .../MongoDbWebhookSubscriptionRepository_T.cs | 10 ++-- .../WebhookNotifierBuilderExtensions.cs | 4 +- .../WebhookSubscriptionBuilderExtensions.cs | 10 ++-- .../Deveel.Webhooks.Service.csproj | 2 +- .../IWebhookDeliveryResultRepository.cs | 5 +- ...WebhookDeliveryResultRepositoryProvider.cs | 7 ++- .../IWebhookSubscriptionRepository.cs | 5 +- .../IWebhookSubscriptionRepositoryProvider.cs | 9 ++-- .../Webhooks/IWebhookSubscriptionValidator.cs | 3 +- .../Webhooks/ServiceCollectionExtensions.cs | 12 +++-- .../TenantWebhookSubscriptionResolver.cs | 15 +++--- .../WebhookNotifierBuilderExtensions.cs | 6 +-- .../Webhooks/WebhookSubscriptionBuilder.cs | 42 ++++++++-------- .../Webhooks/WebhookSubscriptionManager_T.cs | 13 ++--- .../Webhooks/WebhookSubscriptionResolver.cs | 15 +++--- .../Webhooks/WebhookSubscriptionValidator.cs | 8 +-- src/Directory.Build.props | 11 ++-- ...ebhooks.DeliveryResultLogging.Tests.csproj | 2 +- .../Deveel.Webhooks.DynamicLinq.XUnit.csproj | 12 +++++ ...veel.Webhooks.EntityFramework.XUnit.csproj | 20 +++++++- .../EntityDeliveryResultRepositoryTests.cs | 10 ++-- .../EntitySubscriptionResolverTests.cs | 3 +- .../Webhooks/EntityWebhookManagementTests.cs | 6 +-- .../Webhooks/EntityWebhookTestBase.cs | 4 +- .../Webhooks/StorageBuildingTests.cs | 14 +++--- .../Deveel.Webhooks.Management.Tests.csproj | 4 +- .../Webhooks/WebhookManagementTestSuite.cs | 50 ++++++++++--------- .../Deveel.Webhooks.MongoDb.XUnit.csproj | 12 +++++ .../Webhooks/MongoDbConfigurationTests.cs | 10 ++-- .../MongoDbDeliveryResultStoreTests.cs | 24 ++++----- .../Webhooks/MongoDbWebhookTestBase.cs | 7 ++- .../MongoDeliveryResultLoggingTests.cs | 10 ++-- .../MongoSubsctiptionResolverTests.cs | 4 +- .../MongoTenantWebhookManagementTests.cs | 6 +-- .../Webhooks/MongoWebhooksManagementTests.cs | 6 +-- ...TenantWebhookDeliveryResultLoggingTests.cs | 12 +++-- ...el.Webhooks.Receiver.Facebook.XUnit.csproj | 12 +++++ ...hooks.Receiver.NewtonsoftJson.XUnit.csproj | 12 +++++ ...el.Webhooks.Receiver.SendGrid.XUnit.csproj | 12 +++++ .../Deveel.Webhooks.Receiver.Tests.csproj | 1 + ...veel.Webhooks.Receiver.Twilio.XUnit.csproj | 12 +++++ .../Deveel.Webhooks.Receiver.XUnit.csproj | 19 +++++++ .../Deveel.Webhooks.Sender.XUnit.csproj | 12 +++++ .../Webhooks/WebhookSenderTests.cs | 3 ++ .../Deveel.Webhooks.TestHttpClient.csproj | 5 ++ .../Deveel.Webhooks.XUnit.csproj | 12 +++++ .../Webhooks/WebhookServiceTestBase.cs | 4 +- test/Directory.Build.props | 2 +- 72 files changed, 457 insertions(+), 258 deletions(-) diff --git a/samples/WebhookNotifierApp/Controllers/SubscriptionController.cs b/samples/WebhookNotifierApp/Controllers/SubscriptionController.cs index 38c9c93..69977fa 100644 --- a/samples/WebhookNotifierApp/Controllers/SubscriptionController.cs +++ b/samples/WebhookNotifierApp/Controllers/SubscriptionController.cs @@ -4,21 +4,23 @@ using Microsoft.AspNetCore.Mvc; +using MongoDB.Bson; + namespace Deveel.Webhooks.Controllers { [ApiController] [Route("subscriptions")] [Produces("application/json")] public class SubscriptionController : ControllerBase { - private readonly WebhookSubscriptionManager subscriptionManager; + private readonly WebhookSubscriptionManager subscriptionManager; - public SubscriptionController(WebhookSubscriptionManager subscriptionManager) { + public SubscriptionController(WebhookSubscriptionManager subscriptionManager) { this.subscriptionManager = subscriptionManager; } [HttpGet("{id}")] [ProducesResponseType(typeof(MongoWebhookSubscription), 200)] public async Task Get([FromRoute] string id) { - var subscription = await subscriptionManager.FindByKeyAsync(id); + var subscription = await subscriptionManager.FindAsync(ObjectId.Parse(id)); if (subscription == null) return NotFound(); @@ -37,7 +39,7 @@ public async Task Post([FromBody] WebhookSubscriptionModel model) [HttpPut("{id}")] [ProducesResponseType(typeof(MongoWebhookSubscription), 200)] public async Task Put([FromRoute] string id, [FromBody] WebhookSubscriptionModel model) { - var subscription = await subscriptionManager.FindByKeyAsync(id); + var subscription = await subscriptionManager.FindAsync(ObjectId.Parse(id)); if (subscription == null) return NotFound(); @@ -51,7 +53,7 @@ public async Task Put([FromRoute] string id, [FromBody] WebhookSu [HttpDelete("{id}")] [ProducesResponseType(204)] public async Task Delete([FromRoute] string id) { - var subscription = await subscriptionManager.FindByKeyAsync(id); + var subscription = await subscriptionManager.FindAsync(ObjectId.Parse(id)); if (subscription == null) return NotFound(); diff --git a/samples/WebhookNotifierApp/Program.cs b/samples/WebhookNotifierApp/Program.cs index cfba1a2..b23fa39 100644 --- a/samples/WebhookNotifierApp/Program.cs +++ b/samples/WebhookNotifierApp/Program.cs @@ -3,6 +3,8 @@ using Finbuckle.MultiTenant; +using MongoDB.Bson; + namespace Deveel.Webhooks { public class Program { public static void Main(string[] args) { @@ -33,7 +35,7 @@ public static void Main(string[] args) { .UseWebhookFactory() .UseMongoSubscriptionResolver()); - builder.Services.AddWebhookSubscriptions() + builder.Services.AddWebhookSubscriptions() .UseMongoDb("WebhookSubscriptions"); var app = builder.Build(); diff --git a/samples/WebhookNotifierApp/WebhookNotifierApp.csproj b/samples/WebhookNotifierApp/WebhookNotifierApp.csproj index a82ae2c..0c039df 100644 --- a/samples/WebhookNotifierApp/WebhookNotifierApp.csproj +++ b/samples/WebhookNotifierApp/WebhookNotifierApp.csproj @@ -6,6 +6,7 @@ enable Deveel.Webhooks 3a4de43e-1557-46cd-9fda-1aac0a0ee895 + false diff --git a/samples/WebhookReceiverApp.MinimalApi/WebhookReceiverApp.MinimalApi.csproj b/samples/WebhookReceiverApp.MinimalApi/WebhookReceiverApp.MinimalApi.csproj index 08e7a60..537abb0 100644 --- a/samples/WebhookReceiverApp.MinimalApi/WebhookReceiverApp.MinimalApi.csproj +++ b/samples/WebhookReceiverApp.MinimalApi/WebhookReceiverApp.MinimalApi.csproj @@ -6,6 +6,7 @@ enable Deveel.Webhooks f8a59592-accc-4b98-9cc1-46749b23096e + false diff --git a/samples/WebhookReceiverApp/WebhookReceiverApp.csproj b/samples/WebhookReceiverApp/WebhookReceiverApp.csproj index bff2342..e8f3e28 100644 --- a/samples/WebhookReceiverApp/WebhookReceiverApp.csproj +++ b/samples/WebhookReceiverApp/WebhookReceiverApp.csproj @@ -6,6 +6,7 @@ enable Deveel.Webhooks false + false diff --git a/src/Deveel.Webhooks.DynamicLinq/Deveel.Webhooks.DynamicLinq.csproj b/src/Deveel.Webhooks.DynamicLinq/Deveel.Webhooks.DynamicLinq.csproj index f932cdf..c4cda63 100644 --- a/src/Deveel.Webhooks.DynamicLinq/Deveel.Webhooks.DynamicLinq.csproj +++ b/src/Deveel.Webhooks.DynamicLinq/Deveel.Webhooks.DynamicLinq.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Deveel.Webhooks.Receiver.AspNetCore/Deveel.Webhooks.Receiver.AspNetCore.csproj b/src/Deveel.Webhooks.Receiver.AspNetCore/Deveel.Webhooks.Receiver.AspNetCore.csproj index 50ab4df..c5460c1 100644 --- a/src/Deveel.Webhooks.Receiver.AspNetCore/Deveel.Webhooks.Receiver.AspNetCore.csproj +++ b/src/Deveel.Webhooks.Receiver.AspNetCore/Deveel.Webhooks.Receiver.AspNetCore.csproj @@ -22,6 +22,12 @@ + + + + + + diff --git a/src/Deveel.Webhooks.Sender/Deveel.Webhooks.Sender.csproj b/src/Deveel.Webhooks.Sender/Deveel.Webhooks.Sender.csproj index 1d7aec6..0c3eef1 100644 --- a/src/Deveel.Webhooks.Sender/Deveel.Webhooks.Sender.csproj +++ b/src/Deveel.Webhooks.Sender/Deveel.Webhooks.Sender.csproj @@ -16,6 +16,11 @@ + + + + + diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.csproj b/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.csproj index 6e72791..15a18b6 100644 --- a/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.csproj +++ b/src/Deveel.Webhooks.Service.EntityFramework/Deveel.Webhooks.EntityFramework.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository.cs b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository.cs index 4f2b365..a985c97 100644 --- a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository.cs +++ b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository.cs @@ -17,7 +17,7 @@ namespace Deveel.Webhooks { /// - /// An implementation of that + /// An implementation of that /// uses an Entity Framework Core to store the /// delivery results of a webhook of type . /// diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository_T.cs b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository_T.cs index bfd8e13..ae46a00 100644 --- a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository_T.cs +++ b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookDeliveryResultRepository_T.cs @@ -19,15 +19,15 @@ namespace Deveel.Webhooks { /// - /// An implementation of that + /// An implementation of that /// uses an Entity Framework Core to store the /// delivery results of a webhook. /// /// /// The type of delivery result to be stored in the database. /// - public class EntityWebhookDeliveryResultRepository : EntityRepository, - IWebhookDeliveryResultRepository + public class EntityWebhookDeliveryResultRepository : EntityRepository, + IWebhookDeliveryResultRepository where TResult : DbWebhookDeliveryResult { /// @@ -48,7 +48,7 @@ public EntityWebhookDeliveryResultRepository(WebhookDbContext context, ILogger(x => x.Webhook.WebhookId == webhookId, cancellationToken); + return await this.FindFirstAsync(x => x.Webhook.WebhookId == webhookId, cancellationToken); } catch (Exception ex) { throw new WebhookEntityException("Unable to query the database for results", ex); } diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs index 2bd8e1d..a426e9a 100644 --- a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs +++ b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookStorageBuilder.cs @@ -28,9 +28,9 @@ namespace Deveel.Webhooks { /// The type of the entity to use /// public sealed class EntityWebhookStorageBuilder where TSubscription : DbWebhookSubscription { - private readonly WebhookSubscriptionBuilder builder; + private readonly WebhookSubscriptionBuilder builder; - internal EntityWebhookStorageBuilder(WebhookSubscriptionBuilder builder) { + internal EntityWebhookStorageBuilder(WebhookSubscriptionBuilder builder) { this.builder = builder; AddDefaultStorage(); @@ -144,7 +144,7 @@ public EntityWebhookStorageBuilder UseSubscriptionRepository>(); Services.RemoveAll>(); Services.RemoveAll>(); - Services.RemoveAll>(); + Services.RemoveAll>(); Services.RemoveAll>(); Services.RemoveAll(); diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookSubscriptionRepository_T.cs b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookSubscriptionRepository_T.cs index b635cfa..6bcb19e 100644 --- a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookSubscriptionRepository_T.cs +++ b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/EntityWebhookSubscriptionRepository_T.cs @@ -19,16 +19,16 @@ namespace Deveel.Webhooks { /// - /// An implementation of that + /// An implementation of that /// uses an to store the subscriptions. /// /// /// The type of the subscription entity to be stored. /// - /// "/> + /// "/> public class EntityWebhookSubscriptionRepository : - EntityRepository, - IWebhookSubscriptionRepository + EntityRepository, + IWebhookSubscriptionRepository where TSubscription : DbWebhookSubscription { /// @@ -68,7 +68,7 @@ private async Task EnsureLoadedAsync(TSubscription subscription, } /// - protected override async Task OnEntityFoundByKeyAsync(object key, TSubscription entity, CancellationToken cancellationToken = default) + protected override async Task OnEntityFoundByKeyAsync(string key, TSubscription entity, CancellationToken cancellationToken = default) => await EnsureLoadedAsync(entity, cancellationToken); /// diff --git a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/WebhookSubscriptionBuilderExtensions.cs b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/WebhookSubscriptionBuilderExtensions.cs index b5f9f5a..1573f6a 100644 --- a/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/WebhookSubscriptionBuilderExtensions.cs +++ b/src/Deveel.Webhooks.Service.EntityFramework/Webhooks/WebhookSubscriptionBuilderExtensions.cs @@ -14,7 +14,7 @@ namespace Deveel.Webhooks { /// - /// Provides extensions to the + /// Provides extensions to the /// to configure the storage system based on Entity Framework. /// public static class WebhookSubscriptionBuilderExtensions { @@ -25,14 +25,14 @@ public static class WebhookSubscriptionBuilderExtensions { /// The type of the entity to use /// /// - /// The instance of the to + /// The instance of the to /// extend with the Entity Framework storage system. /// /// /// Returns an instance of /// that can be used to configure the storage system. /// - public static EntityWebhookStorageBuilder UseEntityFramework(this WebhookSubscriptionBuilder builder) + public static EntityWebhookStorageBuilder UseEntityFramework(this WebhookSubscriptionBuilder builder) where TSubscription : DbWebhookSubscription => new EntityWebhookStorageBuilder(builder); @@ -43,7 +43,7 @@ public static EntityWebhookStorageBuilder UseEntityFramework entity to use /// /// - /// The instance of the to + /// The instance of the to /// extend with the Entity Framework storage system. /// /// @@ -51,10 +51,10 @@ public static EntityWebhookStorageBuilder UseEntityFramework /// - /// Returns the same instance of + /// Returns the same instance of /// as the input, to allow chaining of calls. /// - public static WebhookSubscriptionBuilder UseEntityFramework(this WebhookSubscriptionBuilder builder, Action> configure) + public static WebhookSubscriptionBuilder UseEntityFramework(this WebhookSubscriptionBuilder builder, Action> configure) where TSubscription : DbWebhookSubscription { var storageBuilder = builder.UseEntityFramework(); configure(storageBuilder); diff --git a/src/Deveel.Webhooks.Service.MongoDb/Deveel.Webhooks.MongoDb.csproj b/src/Deveel.Webhooks.Service.MongoDb/Deveel.Webhooks.MongoDb.csproj index 5206451..bb6d655 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Deveel.Webhooks.MongoDb.csproj +++ b/src/Deveel.Webhooks.Service.MongoDb/Deveel.Webhooks.MongoDb.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryRepositoryRepositoryProvider.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryRepositoryRepositoryProvider.cs index 5333a02..ab34f57 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryRepositoryRepositoryProvider.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryRepositoryRepositoryProvider.cs @@ -14,51 +14,48 @@ using Deveel.Data; -using Finbuckle.MultiTenant; - using Microsoft.Extensions.Logging; -using SharpCompress.Compressors.PPMd; - namespace Deveel.Webhooks { /// - /// Provides an implementation of the - /// that is resolving instances of based + /// Provides an implementation of the + /// that is resolving instances of based /// on the tenant identifier. /// - /// - /// The type of tenant that owns the connection to the MongoDB database - /// /// /// The type of the result that is stored in the database. /// - public class MongoDbWebhookDeliveryResultRepositoryProvider : MongoRepositoryProvider, - IWebhookDeliveryResultRepositoryProvider - where TTenantInfo : class, ITenantInfo, new() - where TResult : MongoWebhookDeliveryResult { + /// + /// The type of the key that is used to identify the result in the database. + /// + public class MongoDbWebhookDeliveryResultRepositoryProvider : MongoRepositoryProvider, + IWebhookDeliveryResultRepositoryProvider + where TResult : MongoWebhookDeliveryResult + where TKey : notnull { /// /// Constructs the provider with the given tenant store. /// - /// - /// The store that is used to resolve the tenant information. - /// + /// + /// A service that is used to resolve the tenant identifier for the + /// current context. + /// /// /// An object that is used to create the logger for the repositories /// created by this provider. /// public MongoDbWebhookDeliveryResultRepositoryProvider( - IEnumerable> tenantStore, + IRepositoryTenantResolver tenantResolver, ILoggerFactory? loggerFactory = null) - : base(tenantStore, loggerFactory) { + : base(tenantResolver, loggerFactory) { } /// - public new async Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default) { - return (IWebhookDeliveryResultRepository) await base.GetRepositoryAsync(tenantId, cancellationToken); + public new async Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default) { + return (IWebhookDeliveryResultRepository) await base.GetRepositoryAsync(tenantId, cancellationToken); } /// - protected override MongoRepository CreateRepository(MongoDbWebhookTenantContext context) - => new MongoDbWebhookDeliveryResultRepository(context, LoggerFactory?.CreateLogger>()); + protected override MongoRepository CreateRepository(MongoDbWebhookTenantContext context) + => new MongoDbWebhookDeliveryResultRepository(context, LoggerFactory?.CreateLogger>()); } } diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultLogger.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultLogger.cs index 5b57dca..3c3b399 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultLogger.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultLogger.cs @@ -15,6 +15,8 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using MongoDB.Bson; + namespace Deveel.Webhooks { /// /// An implementation of that @@ -47,7 +49,7 @@ public class MongoDbWebhookDeliveryResultLogger : IWebhookDel /// An optional logger to use to log messages emitted by this service. /// public MongoDbWebhookDeliveryResultLogger( - IWebhookDeliveryResultRepositoryProvider storeProvider, + IWebhookDeliveryResultRepositoryProvider storeProvider, IMongoWebhookConverter? webhookConverter = null, ILogger>? logger = null) { RepositoryProvider = storeProvider; @@ -59,7 +61,7 @@ public MongoDbWebhookDeliveryResultLogger( /// Gets the provider used to resolve the MongoDB storage where to log /// the delivery results. /// - protected IWebhookDeliveryResultRepositoryProvider RepositoryProvider { get; } + protected IWebhookDeliveryResultRepositoryProvider RepositoryProvider { get; } /// /// Gets the logger used to log messages emitted by this service. diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository.cs index cbe8312..525783b 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository.cs @@ -12,12 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +using MongoDB.Bson; + namespace Deveel.Webhooks { /// - /// A default implementation of the + /// A default implementation of the /// that uses the as the entity /// - public class MongoDbWebhookDeliveryResultRepository : MongoDbWebhookDeliveryResultRepository { + public class MongoDbWebhookDeliveryResultRepository : MongoDbWebhookDeliveryResultRepository { /// /// Constructs the store with the given context. /// diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepositoryProvider.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepositoryProvider.cs index 01ab0f1..6ee775e 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepositoryProvider.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepositoryProvider.cs @@ -12,32 +12,29 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Finbuckle.MultiTenant; +using Deveel.Data; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; + +using MongoDB.Bson; namespace Deveel.Webhooks { /// - /// Provides an implementation of the + /// Provides an implementation of the /// that is backed by a MongoDB database. /// - /// - /// The type of the tenant information. - /// - public class MongoDbWebhookDeliveryResultRepositoryProvider : MongoDbWebhookDeliveryResultRepositoryProvider - where TTenantInfo : class, ITenantInfo, new() { + public class MongoDbWebhookDeliveryResultRepositoryProvider : MongoDbWebhookDeliveryResultRepositoryProvider { /// /// Constructs the store with the given store. /// - /// - /// The store that provides access to the tenants. + /// + /// A service to resolve the current tenant. /// /// /// A factory to create loggers. /// - public MongoDbWebhookDeliveryResultRepositoryProvider(IEnumerable> tenantStore, ILoggerFactory? loggerFactory = null) - : base(tenantStore, loggerFactory) { + public MongoDbWebhookDeliveryResultRepositoryProvider(IRepositoryTenantResolver tenantResolver, ILoggerFactory? loggerFactory = null) + : base(tenantResolver, loggerFactory) { } } } diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository_T.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository_T.cs index 7d7fe45..1eac427 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository_T.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookDeliveryResultRepository_T.cs @@ -24,14 +24,15 @@ namespace Deveel.Webhooks { /// - /// Provides an implementation of the + /// Provides an implementation of the /// that is backed by a MongoDB database. /// /// /// The type of the result that is stored in the database. /// - public class MongoDbWebhookDeliveryResultRepository : MongoRepository, - IWebhookDeliveryResultRepository + public class MongoDbWebhookDeliveryResultRepository : MongoRepository, + IWebhookDeliveryResultRepository + where TKey : notnull where TResult : MongoWebhookDeliveryResult { /// @@ -43,7 +44,7 @@ public class MongoDbWebhookDeliveryResultRepository : MongoRepository /// An object to use for logging operations. /// - public MongoDbWebhookDeliveryResultRepository(IMongoDbWebhookContext context, ILogger>? logger = null) + public MongoDbWebhookDeliveryResultRepository(IMongoDbWebhookContext context, ILogger>? logger = null) : base(context, logger) { } diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookStorageBuilder.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookStorageBuilder.cs index f0a2f9e..8873bad 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookStorageBuilder.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookStorageBuilder.cs @@ -22,6 +22,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using MongoDB.Bson; + namespace Deveel.Webhooks { /// /// Provides a builder to configure the MongoDB storage of webhook entities @@ -30,9 +32,9 @@ namespace Deveel.Webhooks { /// The type of the subscription entity to store in the database. /// public sealed class MongoDbWebhookStorageBuilder where TSubscription : MongoWebhookSubscription { - private readonly WebhookSubscriptionBuilder builder; + private readonly WebhookSubscriptionBuilder builder; - internal MongoDbWebhookStorageBuilder(WebhookSubscriptionBuilder builder) { + internal MongoDbWebhookStorageBuilder(WebhookSubscriptionBuilder builder) { this.builder = builder; AddDefaultStorage(); @@ -121,6 +123,8 @@ public MongoDbWebhookStorageBuilder WithTenantConnection(Action(); Services.RemoveAll>(); + Services.AddRepositoryTenantResolver(); + Services.AddMongoDbContext((tenant, builder) => { if (tenant == null) throw new Exception("No tenant information was provided"); @@ -129,8 +133,8 @@ public MongoDbWebhookStorageBuilder WithTenantConnection(Action(sp => sp.GetRequiredService()); - Services.AddRepositoryProvider>(); - Services.AddRepositoryProvider>(); + Services.AddRepositoryProvider>(); + Services.AddRepositoryProvider(); return this; } @@ -158,7 +162,7 @@ public MongoDbWebhookStorageBuilder UseMultiTenant() public MongoDbWebhookStorageBuilder UseSubscriptionRepository() where TRepository : MongoDbWebhookSubscriptionRepository { Services.RemoveAll>(); - Services.RemoveAll>(); + Services.RemoveAll>(); Services.AddRepository(); diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository.cs index a7ee7ad..18fd0d0 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository.cs @@ -14,11 +14,13 @@ using Microsoft.Extensions.Logging; +using MongoDB.Bson; + namespace Deveel.Webhooks { /// - /// Provides an implementation of the + /// Provides an implementation of the /// - public class MongoDbWebhookSubscriptionRepository : MongoDbWebhookSubscriptionRepository { + public class MongoDbWebhookSubscriptionRepository : MongoDbWebhookSubscriptionRepository { /// public MongoDbWebhookSubscriptionRepository(IMongoDbWebhookContext context, ILogger? logger = null) : base(context, logger) { diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider.cs index 0459fad..8429dcf 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider.cs @@ -12,11 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Deveel.Data; + using Finbuckle.MultiTenant; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using MongoDB.Bson; + namespace Deveel.Webhooks { /// /// A default implementation of the @@ -28,17 +32,16 @@ namespace Deveel.Webhooks { /// /// The type of the tenant information. /// - public class MongoDbWebhookSubscriptionRepositoryProvider : MongoDbWebhookSubscriptionRepositoryProvider, - IWebhookSubscriptionRepositoryProvider - where TContext : class, IMongoDbWebhookContext - where TTenantInfo : class, ITenantInfo, new() { + public class MongoDbWebhookSubscriptionRepositoryProvider : MongoDbWebhookSubscriptionRepositoryProvider, + IWebhookSubscriptionRepositoryProvider + where TContext : class, IMongoDbWebhookContext { /// - public MongoDbWebhookSubscriptionRepositoryProvider(IEnumerable> tenantStore, ILoggerFactory? loggerFactory = null) - : base(tenantStore, loggerFactory) { + public MongoDbWebhookSubscriptionRepositoryProvider(IRepositoryTenantResolver tenantResolver, ILoggerFactory? loggerFactory = null) + : base(tenantResolver, loggerFactory) { } /// - public new async Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default) - => (IWebhookSubscriptionRepository) (await base.GetRepositoryAsync(tenantId)); + public new async Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default) + => (IWebhookSubscriptionRepository) (await base.GetRepositoryAsync(tenantId)); } } diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider_T.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider_T.cs index fe06ef7..e0e5852 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider_T.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepositoryProvider_T.cs @@ -33,11 +33,11 @@ namespace Deveel.Webhooks { /// /// The type of the tenant information used to identify the MongoDB database /// - public class MongoDbWebhookSubscriptionRepositoryProvider : - MongoRepositoryProvider, - IWebhookSubscriptionRepositoryProvider, IDisposable + public class MongoDbWebhookSubscriptionRepositoryProvider : + MongoRepositoryProvider, + IWebhookSubscriptionRepositoryProvider, IDisposable where TContext : class, IMongoDbWebhookContext - where TTenantInfo : class, ITenantInfo, new() + where TKey : notnull where TSubscription : MongoWebhookSubscription { /// @@ -50,17 +50,17 @@ public class MongoDbWebhookSubscriptionRepositoryProvider - public MongoDbWebhookSubscriptionRepositoryProvider(IEnumerable> tenantStore, ILoggerFactory? loggerFactory = null) - : base(tenantStore, loggerFactory) { + public MongoDbWebhookSubscriptionRepositoryProvider(IRepositoryTenantResolver tenantResolver, ILoggerFactory? loggerFactory = null) + : base(tenantResolver, loggerFactory) { } /// - protected override MongoRepository CreateRepository(TContext context) - => new MongoDbWebhookSubscriptionRepository(context, LoggerFactory?.CreateLogger>()); + protected override MongoRepository CreateRepository(TContext context) + => new MongoDbWebhookSubscriptionRepository(context, LoggerFactory?.CreateLogger>()); /// - public new async Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default) - => (IWebhookSubscriptionRepository)(await base.GetRepositoryAsync(tenantId)); + public new async Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default) + => (IWebhookSubscriptionRepository)(await base.GetRepositoryAsync(tenantId)); } } diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository_T.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository_T.cs index 1059ca0..725712b 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository_T.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/MongoDbWebhookSubscriptionRepository_T.cs @@ -23,16 +23,16 @@ namespace Deveel.Webhooks { /// - /// Provides an implementation of the + /// Provides an implementation of the /// that is backed by a MongoDB database. /// /// /// The type of the webhook subscription, that is /// derived from . /// - public class MongoDbWebhookSubscriptionRepository : - MongoRepository, - IWebhookSubscriptionRepository + public class MongoDbWebhookSubscriptionRepository : + MongoRepository, + IWebhookSubscriptionRepository where TSubscription : MongoWebhookSubscription { /// @@ -47,7 +47,7 @@ public class MongoDbWebhookSubscriptionRepository : /// /// Thrown when the given is null. /// - public MongoDbWebhookSubscriptionRepository(IMongoDbWebhookContext context, ILogger>? logger = null) + public MongoDbWebhookSubscriptionRepository(IMongoDbWebhookContext context, ILogger>? logger = null) : base(context, logger) { } diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookNotifierBuilderExtensions.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookNotifierBuilderExtensions.cs index 807cbfd..f7d6c61 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookNotifierBuilderExtensions.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookNotifierBuilderExtensions.cs @@ -14,6 +14,8 @@ using Microsoft.Extensions.DependencyInjection; +using MongoDB.Bson; + namespace Deveel.Webhooks { /// /// Provides extensions to the @@ -56,7 +58,7 @@ public static WebhookNotifierBuilder UseMongoSubscriptionResolver public static WebhookNotifierBuilder UseMongoTenantSubscriptionResolver(this WebhookNotifierBuilder builder) where TWebhook : class { - return builder.UseDefaultTenantSubscriptionResolver(typeof(MongoWebhookSubscription)); + return builder.UseDefaultTenantSubscriptionResolver(typeof(MongoWebhookSubscription), typeof(ObjectId)); } /// diff --git a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookSubscriptionBuilderExtensions.cs b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookSubscriptionBuilderExtensions.cs index 4dd7f0f..aaf6f79 100644 --- a/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookSubscriptionBuilderExtensions.cs +++ b/src/Deveel.Webhooks.Service.MongoDb/Webhooks/WebhookSubscriptionBuilderExtensions.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using MongoDB.Bson; + namespace Deveel.Webhooks { /// /// Provides extensions to the @@ -32,7 +34,7 @@ public static class WebhookSubscriptionBuilderExtensions { /// Returns an instance of /// used to further configure the storage. /// - public static MongoDbWebhookStorageBuilder UseMongoDb(this WebhookSubscriptionBuilder builder) + public static MongoDbWebhookStorageBuilder UseMongoDb(this WebhookSubscriptionBuilder builder) where TSubscription : MongoWebhookSubscription => new MongoDbWebhookStorageBuilder(builder); @@ -54,7 +56,7 @@ public static MongoDbWebhookStorageBuilder UseMongoDb /// used to further configure the storage. /// - public static MongoDbWebhookStorageBuilder UseMongoDb(this WebhookSubscriptionBuilder builder, string connectionString) + public static MongoDbWebhookStorageBuilder UseMongoDb(this WebhookSubscriptionBuilder builder, string connectionString) where TSubscription : MongoWebhookSubscription => builder.UseMongoDb().WithConnectionString(connectionString); @@ -74,10 +76,10 @@ public static MongoDbWebhookStorageBuilder UseMongoDb /// - /// Returns the instance of + /// Returns the instance of /// with the registered storage. /// - public static WebhookSubscriptionBuilder UseMongoDb(this WebhookSubscriptionBuilder builder, Action> configure) + public static WebhookSubscriptionBuilder UseMongoDb(this WebhookSubscriptionBuilder builder, Action> configure) where TSubscription : MongoWebhookSubscription { var storageBuilder = new MongoDbWebhookStorageBuilder(builder); configure?.Invoke(storageBuilder); diff --git a/src/Deveel.Webhooks.Service/Deveel.Webhooks.Service.csproj b/src/Deveel.Webhooks.Service/Deveel.Webhooks.Service.csproj index 97a8f08..980184b 100644 --- a/src/Deveel.Webhooks.Service/Deveel.Webhooks.Service.csproj +++ b/src/Deveel.Webhooks.Service/Deveel.Webhooks.Service.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepository.cs b/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepository.cs index 7d983b7..b9916a8 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepository.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepository.cs @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System; -using System.Threading.Tasks; -using System.Threading; using Deveel.Data; namespace Deveel.Webhooks { @@ -24,7 +21,7 @@ namespace Deveel.Webhooks { /// /// The type of the result of the delivery of a webhook /// - public interface IWebhookDeliveryResultRepository : IRepository where TResult : class, IWebhookDeliveryResult { + public interface IWebhookDeliveryResultRepository : IRepository where TResult : class, IWebhookDeliveryResult { /// /// Finds a single delivery result by the identifier of the webhook /// that was set during the notification process. diff --git a/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepositoryProvider.cs b/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepositoryProvider.cs index cbebb1a..b755b11 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepositoryProvider.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/IWebhookDeliveryResultRepositoryProvider.cs @@ -24,7 +24,10 @@ namespace Deveel.Webhooks { /// /// The type of the result of the delivery of a webhook. /// - public interface IWebhookDeliveryResultRepositoryProvider : IRepositoryProvider + /// + /// The type of the key that is used to identify the result in the database. + /// + public interface IWebhookDeliveryResultRepositoryProvider : IRepositoryProvider where TResult : class, IWebhookDeliveryResult { /// /// Gets the repository of delivery results for the given tenant. @@ -42,6 +45,6 @@ public interface IWebhookDeliveryResultRepositoryProvider : IRepository /// /// Thrown if the repository cannot be resolved for the given tenant. /// - new Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default); + new Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default); } } diff --git a/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepository.cs b/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepository.cs index df08817..6718f31 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepository.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepository.cs @@ -21,8 +21,9 @@ namespace Deveel.Webhooks { /// /// The type of webhook subscription that is handled by the store. /// - public interface IWebhookSubscriptionRepository : IRepository - where TSubscription : class, IWebhookSubscription { + public interface IWebhookSubscriptionRepository : IRepository + where TSubscription : class, IWebhookSubscription + where TKey : notnull { /// /// Gets the URL of the destination where to deliver the /// webhook events for the given subscription. diff --git a/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepositoryProvider.cs b/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepositoryProvider.cs index f64fbc4..339b6a1 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepositoryProvider.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionRepositoryProvider.cs @@ -24,8 +24,9 @@ namespace Deveel.Webhooks { /// /// The type of subscription that is stored in the store /// - public interface IWebhookSubscriptionRepositoryProvider : IRepositoryProvider - where TSubscription : class, IWebhookSubscription { + public interface IWebhookSubscriptionRepositoryProvider : IRepositoryProvider + where TSubscription : class, IWebhookSubscription + where TKey : notnull { /// /// Gets the store for the given tenant /// @@ -36,9 +37,9 @@ public interface IWebhookSubscriptionRepositoryProvider : IReposi /// A cancellation token used to cancel the operation. /// /// - /// Returns an instance of + /// Returns an instance of /// that is used to store the subscriptions for the given tenant. /// - new Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default); + new Task> GetRepositoryAsync(string tenantId, CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionValidator.cs b/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionValidator.cs index 3270119..5f86178 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionValidator.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/IWebhookSubscriptionValidator.cs @@ -22,7 +22,8 @@ namespace Deveel.Webhooks { /// /// The type of the subscription to validate. /// - public interface IWebhookSubscriptionValidator : IEntityValidator + public interface IWebhookSubscriptionValidator : IEntityValidator + where TKey : notnull where TSubscription : class, IWebhookSubscription { } } diff --git a/src/Deveel.Webhooks.Service/Webhooks/ServiceCollectionExtensions.cs b/src/Deveel.Webhooks.Service/Webhooks/ServiceCollectionExtensions.cs index ab78fb1..2cb3d86 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/ServiceCollectionExtensions.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/ServiceCollectionExtensions.cs @@ -35,10 +35,11 @@ public static class ServiceCollectionExtensions { /// /// Returns the collection where the webhook management service is registered. /// - public static IServiceCollection AddWebhookSubscriptions(this IServiceCollection services, Action>? configure = null) + public static IServiceCollection AddWebhookSubscriptions(this IServiceCollection services, Action>? configure = null) + where TKey : notnull where TSubscription : class, IWebhookSubscription { - var builder = services.AddWebhookSubscriptions(); + var builder = services.AddWebhookSubscriptions(); configure?.Invoke(builder); return services; @@ -57,9 +58,10 @@ public static IServiceCollection AddWebhookSubscriptions(this ISe /// /// Returns the builder used to configure the service. /// - public static WebhookSubscriptionBuilder AddWebhookSubscriptions(this IServiceCollection services) - where TSubscription : class, IWebhookSubscription { - var builder = new WebhookSubscriptionBuilder(services); + public static WebhookSubscriptionBuilder AddWebhookSubscriptions(this IServiceCollection services) + where TSubscription : class, IWebhookSubscription + where TKey : notnull { + var builder = new WebhookSubscriptionBuilder(services); services.TryAddSingleton(builder); diff --git a/src/Deveel.Webhooks.Service/Webhooks/TenantWebhookSubscriptionResolver.cs b/src/Deveel.Webhooks.Service/Webhooks/TenantWebhookSubscriptionResolver.cs index 4576a97..de6616d 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/TenantWebhookSubscriptionResolver.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/TenantWebhookSubscriptionResolver.cs @@ -25,14 +25,15 @@ namespace Deveel.Webhooks { /// /// The type of the subscription to be resolved. /// - public class TenantWebhookSubscriptionResolver : ITenantWebhookSubscriptionResolver - where TSubscription : class, IWebhookSubscription { - private readonly IWebhookSubscriptionRepositoryProvider storeProvider; + public class TenantWebhookSubscriptionResolver : ITenantWebhookSubscriptionResolver + where TSubscription : class, IWebhookSubscription + where TKey : notnull { + private readonly IWebhookSubscriptionRepositoryProvider storeProvider; private readonly IWebhookSubscriptionCache? cache; private ILogger logger; /// - /// Constructs a + /// Constructs a /// backed by a given store provider. /// /// @@ -46,12 +47,12 @@ public class TenantWebhookSubscriptionResolver : ITenantWebhookSu /// An optional logger to be used to log the operations. /// public TenantWebhookSubscriptionResolver( - IWebhookSubscriptionRepositoryProvider storeProvider, + IWebhookSubscriptionRepositoryProvider storeProvider, IWebhookSubscriptionCache? cache = null, - ILogger>? logger = null) { + ILogger>? logger = null) { this.storeProvider = storeProvider; this.cache = cache; - this.logger = logger ?? NullLogger>.Instance; + this.logger = logger ?? NullLogger>.Instance; } private async Task?> GetCachedAsync(string tenantId, string eventType, CancellationToken cancellationToken) { diff --git a/src/Deveel.Webhooks.Service/Webhooks/WebhookNotifierBuilderExtensions.cs b/src/Deveel.Webhooks.Service/Webhooks/WebhookNotifierBuilderExtensions.cs index a389673..6259cea 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/WebhookNotifierBuilderExtensions.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/WebhookNotifierBuilderExtensions.cs @@ -30,12 +30,12 @@ public static class WebhookNotifierBuilderExtensions { /// /// /// - public static WebhookNotifierBuilder UseDefaultTenantSubscriptionResolver(this WebhookNotifierBuilder builder, Type subscriptionType, ServiceLifetime lifetime = ServiceLifetime.Scoped) + public static WebhookNotifierBuilder UseDefaultTenantSubscriptionResolver(this WebhookNotifierBuilder builder, Type subscriptionType, Type keyType, ServiceLifetime lifetime = ServiceLifetime.Scoped) where TWebhook : class { if (!typeof(IWebhookSubscription).IsAssignableFrom(subscriptionType)) throw new ArgumentException("The type specified is not a subscription type", nameof(subscriptionType)); - var resolverType = typeof(TenantWebhookSubscriptionResolver<>).MakeGenericType(subscriptionType); + var resolverType = typeof(TenantWebhookSubscriptionResolver<,>).MakeGenericType(subscriptionType, keyType); return builder.UseTenantSubscriptionResolver(resolverType, lifetime); } @@ -54,7 +54,7 @@ public static WebhookNotifierBuilder UseDefaultSubscriptionResolver).MakeGenericType(subscriptionType); + var resolverType = typeof(WebhookSubscriptionResolver<,>).MakeGenericType(subscriptionType, typeof(string)); return builder.UseSubscriptionResolver(resolverType, lifetime); } } diff --git a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionBuilder.cs b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionBuilder.cs index 049f3c8..3c4b551 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionBuilder.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionBuilder.cs @@ -24,9 +24,11 @@ namespace Deveel.Webhooks { /// /// The type of the subscription that is used to notify webhooks. /// - public sealed class WebhookSubscriptionBuilder where TSubscription : class, IWebhookSubscription { + public sealed class WebhookSubscriptionBuilder + where TSubscription : class, IWebhookSubscription + where TKey : notnull { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The collection of services that are used to configure the webhook services. @@ -50,16 +52,16 @@ public WebhookSubscriptionBuilder(IServiceCollection services) { public IServiceCollection Services { get; } private void RegisterDefaults() { - Services.TryAddScoped>(); - Services.TryAddSingleton, WebhookSubscriptionValidator>(); + Services.TryAddScoped>(); + Services.TryAddSingleton, WebhookSubscriptionValidator>(); - Services.TryAddScoped>(); - Services.TryAddScoped>(); + Services.TryAddScoped>(); + Services.TryAddScoped>(); // Services.TryAddScoped>(); } /// - /// Registers a custom + /// Registers a custom /// that overrides the default one. /// /// @@ -69,30 +71,30 @@ private void RegisterDefaults() { /// The service lifetime of the manager to be registered. /// /// - /// Returns this instance of the . + /// Returns this instance of the . /// - public WebhookSubscriptionBuilder UseSubscriptionManager(ServiceLifetime lifetime = ServiceLifetime.Scoped) - where TManager : WebhookSubscriptionManager { + public WebhookSubscriptionBuilder UseSubscriptionManager(ServiceLifetime lifetime = ServiceLifetime.Scoped) + where TManager : WebhookSubscriptionManager { Services.RemoveAll>(); - Services.RemoveAll>(); + Services.RemoveAll>(); - Services.TryAdd(new ServiceDescriptor(typeof(WebhookSubscriptionManager), typeof(TManager), lifetime)); + Services.TryAdd(new ServiceDescriptor(typeof(WebhookSubscriptionManager), typeof(TManager), lifetime)); - if (typeof(TManager) != typeof(WebhookSubscriptionManager)) + if (typeof(TManager) != typeof(WebhookSubscriptionManager)) Services.Add(new ServiceDescriptor(typeof(TManager), typeof(TManager), lifetime)); return this; } /// - /// Registers the default + /// Registers the default /// /// - /// Returns this instance of the . + /// Returns this instance of the . /// - public WebhookSubscriptionBuilder UseSubscriptionManager() - => UseSubscriptionManager>(); + public WebhookSubscriptionBuilder UseSubscriptionManager() + => UseSubscriptionManager>(); /// /// Adds a validator of webhook subscriptions. @@ -104,10 +106,10 @@ public WebhookSubscriptionBuilder UseSubscriptionManager() /// The service lifetime of the validator to be registered. /// /// - /// Returns this instance of the . + /// Returns this instance of the . /// - public WebhookSubscriptionBuilder AddSubscriptionValidator(ServiceLifetime lifetime = ServiceLifetime.Singleton) - where TValidator : class, IWebhookSubscriptionValidator { + public WebhookSubscriptionBuilder AddSubscriptionValidator(ServiceLifetime lifetime = ServiceLifetime.Singleton) + where TValidator : class, IWebhookSubscriptionValidator { Services.AddEntityValidator(lifetime); diff --git a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionManager_T.cs b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionManager_T.cs index 4d14f66..0393420 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionManager_T.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionManager_T.cs @@ -24,7 +24,8 @@ namespace Deveel.Webhooks { /// /// The type of the subscription handled by the manager. /// - public class WebhookSubscriptionManager : EntityManager + public class WebhookSubscriptionManager : EntityManager + where TKey : notnull where TSubscription : class, IWebhookSubscription { /// /// Creates a new instance of the manager wrapping a given store @@ -46,10 +47,10 @@ public class WebhookSubscriptionManager : EntityManager //TODO: add an Error Factory for Webhook Subscriptions public WebhookSubscriptionManager( - IWebhookSubscriptionRepository subscriptionStore, - IWebhookSubscriptionValidator? validator = null, + IWebhookSubscriptionRepository subscriptionStore, + IWebhookSubscriptionValidator? validator = null, IServiceProvider? services = null, - ILogger>? logger = null) + ILogger>? logger = null) : base(subscriptionStore, validator, services: services) { } @@ -63,10 +64,10 @@ public WebhookSubscriptionManager( /// Gets an instance of the repository that implements /// the webhook subscriptions operations. /// - protected virtual IWebhookSubscriptionRepository SubscriptionRepository { + protected virtual IWebhookSubscriptionRepository SubscriptionRepository { get { ThrowIfDisposed(); - return (IWebhookSubscriptionRepository) base.Repository; + return (IWebhookSubscriptionRepository) base.Repository; } } diff --git a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionResolver.cs b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionResolver.cs index adae585..317adfb 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionResolver.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionResolver.cs @@ -25,14 +25,15 @@ namespace Deveel.Webhooks { /// /// The type of the subscription to be resolved. /// - public class WebhookSubscriptionResolver : IWebhookSubscriptionResolver - where TSubscription : class, IWebhookSubscription { - private readonly IWebhookSubscriptionRepository repository; + public class WebhookSubscriptionResolver : IWebhookSubscriptionResolver + where TSubscription : class, IWebhookSubscription + where TKey : notnull { + private readonly IWebhookSubscriptionRepository repository; private readonly IWebhookSubscriptionCache? cache; private ILogger logger; /// - /// Constructs a + /// Constructs a /// backed by a given store. /// /// @@ -46,12 +47,12 @@ public class WebhookSubscriptionResolver : IWebhookSubscriptionRe /// An optional logger to be used to log the operations. /// public WebhookSubscriptionResolver( - IWebhookSubscriptionRepository repository, + IWebhookSubscriptionRepository repository, IWebhookSubscriptionCache? cache = null, - ILogger>? logger = null) { + ILogger>? logger = null) { this.repository = repository; this.cache = cache; - this.logger = logger ?? NullLogger>.Instance; + this.logger = logger ?? NullLogger>.Instance; } private async Task?> GetCachedAsync(string eventType, CancellationToken cancellationToken) { diff --git a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionValidator.cs b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionValidator.cs index 174f20c..2333e46 100644 --- a/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionValidator.cs +++ b/src/Deveel.Webhooks.Service/Webhooks/WebhookSubscriptionValidator.cs @@ -19,12 +19,14 @@ namespace Deveel.Webhooks { /// - /// A default implementation of the + /// A default implementation of the /// /// /// The type of the subscription that is validated. /// - public class WebhookSubscriptionValidator : IWebhookSubscriptionValidator where TSubscription : class, IWebhookSubscription { + public class WebhookSubscriptionValidator : IWebhookSubscriptionValidator + where TKey : notnull + where TSubscription : class, IWebhookSubscription { /// /// Validates the given to have /// the required properties to be registered @@ -42,7 +44,7 @@ public class WebhookSubscriptionValidator : IWebhookSubscriptionV /// Returns an that yields /// all the validation results. /// - public virtual async IAsyncEnumerable ValidateAsync(EntityManager manager, TSubscription subscription, [EnumeratorCancellation] CancellationToken cancellationToken) { + public virtual async IAsyncEnumerable ValidateAsync(EntityManager manager, TSubscription subscription, [EnumeratorCancellation] CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (!ValidateUrl(subscription, out var result)) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index c0a8471..4e63426 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,10 +1,10 @@ - net6.0;net7.0 + net6.0;net7.0;net8.0 enable enable - 2.1.5 + 2.2.0 Deveel true @@ -12,8 +12,8 @@ false true antonello - Deveel AS - Copyright (C) 2021-2023 Deveel AS + Deveel + Copyright (C) 2021-2024 Antonello Provenzano Apache-2.0 https://webhooks.deveel.org deveel-logo.png @@ -31,7 +31,8 @@ - + + diff --git a/test/Deveel.Webhooks.DeliveryResultLogging.Tests/Deveel.Webhooks.DeliveryResultLogging.Tests.csproj b/test/Deveel.Webhooks.DeliveryResultLogging.Tests/Deveel.Webhooks.DeliveryResultLogging.Tests.csproj index 99e9670..f8a7cc4 100644 --- a/test/Deveel.Webhooks.DeliveryResultLogging.Tests/Deveel.Webhooks.DeliveryResultLogging.Tests.csproj +++ b/test/Deveel.Webhooks.DeliveryResultLogging.Tests/Deveel.Webhooks.DeliveryResultLogging.Tests.csproj @@ -8,7 +8,7 @@ - + diff --git a/test/Deveel.Webhooks.DynamicLinq.XUnit/Deveel.Webhooks.DynamicLinq.XUnit.csproj b/test/Deveel.Webhooks.DynamicLinq.XUnit/Deveel.Webhooks.DynamicLinq.XUnit.csproj index a7d48b3..4fde58f 100644 --- a/test/Deveel.Webhooks.DynamicLinq.XUnit/Deveel.Webhooks.DynamicLinq.XUnit.csproj +++ b/test/Deveel.Webhooks.DynamicLinq.XUnit/Deveel.Webhooks.DynamicLinq.XUnit.csproj @@ -12,4 +12,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/Deveel.Webhooks.EntityFramework.XUnit/Deveel.Webhooks.EntityFramework.XUnit.csproj b/test/Deveel.Webhooks.EntityFramework.XUnit/Deveel.Webhooks.EntityFramework.XUnit.csproj index ebbd546..1b2679d 100644 --- a/test/Deveel.Webhooks.EntityFramework.XUnit/Deveel.Webhooks.EntityFramework.XUnit.csproj +++ b/test/Deveel.Webhooks.EntityFramework.XUnit/Deveel.Webhooks.EntityFramework.XUnit.csproj @@ -10,14 +10,30 @@ - + + + + + - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityDeliveryResultRepositoryTests.cs b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityDeliveryResultRepositoryTests.cs index 41d4e8b..3c04ecb 100644 --- a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityDeliveryResultRepositoryTests.cs +++ b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityDeliveryResultRepositoryTests.cs @@ -17,8 +17,8 @@ public EntityDeliveryResultRepositoryTests(SqliteTestDatabase sqlite, ITestOutpu eventFaker = new DbEventInfoFaker(); } - private IWebhookDeliveryResultRepository Repository - => Services.GetRequiredService>(); + private IWebhookDeliveryResultRepository Repository + => Services.GetRequiredService>(); public override async Task InitializeAsync() { await base.InitializeAsync(); @@ -51,7 +51,7 @@ public async Task CreateNewResult() { public async Task GetExistingResult() { var result = NextRandom(); - var found = await Repository.FindByKeyAsync(result.Id!); + var found = await Repository.FindAsync(result.Id!.Value); Assert.NotNull(found); Assert.Equal(result.Id, found.Id); @@ -73,7 +73,7 @@ public async Task GetExistingResult() { public async Task GetNotExistingResult() { var resultId = Random.Shared.Next(results!.Max(x => x.Id!.Value) + 1, Int32.MaxValue); - var found = await Repository.FindByKeyAsync(resultId!); + var found = await Repository.FindAsync(resultId!); Assert.Null(found); } @@ -86,7 +86,7 @@ public async Task RemoveExistingResult() { Assert.True(deleted); - var found = await Repository.FindByKeyAsync(result.Id!); + var found = await Repository.FindAsync(result.Id!.Value); Assert.Null(found); } diff --git a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntitySubscriptionResolverTests.cs b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntitySubscriptionResolverTests.cs index fb95e91..295d91d 100644 --- a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntitySubscriptionResolverTests.cs +++ b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntitySubscriptionResolverTests.cs @@ -14,7 +14,8 @@ public EntitySubscriptionResolverTests(SqliteTestDatabase sqlite, ITestOutputHel protected IList Subscriptions { get; private set; } - protected IRepository Repository => Services.GetRequiredService>(); + protected IRepository Repository + => Services.GetRequiredService>(); public IWebhookSubscriptionResolver Resolver => Services.GetRequiredService(); diff --git a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookManagementTests.cs b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookManagementTests.cs index 86f13dd..4a61901 100644 --- a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookManagementTests.cs +++ b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookManagementTests.cs @@ -7,7 +7,7 @@ namespace Deveel.Webhooks { [Collection(nameof(EntityWebhookManagementTestCollection))] - public class EntityWebhookManagementTests : WebhookManagementTestSuite { + public class EntityWebhookManagementTests : WebhookManagementTestSuite { private readonly SqliteTestDatabase sql; public EntityWebhookManagementTests(SqliteTestDatabase sql, ITestOutputHelper testOutput) : base(testOutput) { @@ -16,9 +16,9 @@ public EntityWebhookManagementTests(SqliteTestDatabase sql, ITestOutputHelper te protected override Faker Faker => new DbWebhookSubscriptionFaker(); - protected override object GenerateSubscriptionKey() => Guid.NewGuid().ToString(); + protected override string GenerateSubscriptionKey() => Guid.NewGuid().ToString(); - protected override void ConfigureWebhookStorage(WebhookSubscriptionBuilder options) + protected override void ConfigureWebhookStorage(WebhookSubscriptionBuilder options) => options.UseEntityFramework(builder => builder.UseContext(ctx => ctx.UseSqlite(sql.Connection))); protected override async Task InitializeAsync() { diff --git a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookTestBase.cs b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookTestBase.cs index d90b165..e5984e8 100644 --- a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookTestBase.cs +++ b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/EntityWebhookTestBase.cs @@ -27,7 +27,7 @@ protected EntityWebhookTestBase(SqliteTestDatabase sqlite, ITestOutputHelper out private IServiceProvider BuildServiceProvider() { var services = new ServiceCollection(); - services.AddWebhookSubscriptions(builder => ConfigureWebhookService(builder)) + services.AddWebhookSubscriptions(builder => ConfigureWebhookService(builder)) .AddTestHttpClient(OnRequestAsync) .AddLogging(logging => logging.AddXUnit(outputHelper)); @@ -40,7 +40,7 @@ protected virtual Task OnRequestAsync(HttpRequestMessage me return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)); } - protected virtual void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { + protected virtual void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { builder.UseEntityFramework(ConfigureWebhookEntityFramework); } diff --git a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/StorageBuildingTests.cs b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/StorageBuildingTests.cs index 72f7dc8..eaebf87 100644 --- a/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/StorageBuildingTests.cs +++ b/test/Deveel.Webhooks.EntityFramework.XUnit/Webhooks/StorageBuildingTests.cs @@ -9,13 +9,13 @@ public static class StorageBuildingTests { [Fact] public static void UseDefaultRepository() { var services = new ServiceCollection(); - services.AddWebhookSubscriptions() + services.AddWebhookSubscriptions() .UseEntityFramework(ef => ef.UseContext(options => options.UseSqlite())); var provider = services.BuildServiceProvider(); - Assert.NotNull(provider.GetService>()); - Assert.NotNull(provider.GetService>()); + Assert.NotNull(provider.GetService>()); + Assert.NotNull(provider.GetService>()); Assert.NotNull(provider.GetService>()); Assert.NotNull(provider.GetService()); } @@ -23,20 +23,20 @@ public static void UseDefaultRepository() { [Fact] public static void UseCustomRepository() { var services = new ServiceCollection(); - services.AddWebhookSubscriptions() + services.AddWebhookSubscriptions() .UseEntityFramework(ef => ef .UseContext(options => options.UseSqlite()) .UseSubscriptionRepository()); var provider = services.BuildServiceProvider(); - Assert.NotNull(provider.GetService>()); - Assert.NotNull(provider.GetService>()); + Assert.NotNull(provider.GetService>()); + Assert.NotNull(provider.GetService>()); Assert.NotNull(provider.GetService()); Assert.NotNull(provider.GetService>()); Assert.Null(provider.GetService()); - var repository = provider.GetService>(); + var repository = provider.GetService>(); Assert.IsType(repository); } diff --git a/test/Deveel.Webhooks.Management.Tests/Deveel.Webhooks.Management.Tests.csproj b/test/Deveel.Webhooks.Management.Tests/Deveel.Webhooks.Management.Tests.csproj index 1f171e4..712736b 100644 --- a/test/Deveel.Webhooks.Management.Tests/Deveel.Webhooks.Management.Tests.csproj +++ b/test/Deveel.Webhooks.Management.Tests/Deveel.Webhooks.Management.Tests.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/test/Deveel.Webhooks.Management.Tests/Webhooks/WebhookManagementTestSuite.cs b/test/Deveel.Webhooks.Management.Tests/Webhooks/WebhookManagementTestSuite.cs index 8bdd495..ed46d81 100644 --- a/test/Deveel.Webhooks.Management.Tests/Webhooks/WebhookManagementTestSuite.cs +++ b/test/Deveel.Webhooks.Management.Tests/Webhooks/WebhookManagementTestSuite.cs @@ -11,7 +11,9 @@ using Xunit.Abstractions; namespace Deveel.Webhooks { - public abstract class WebhookManagementTestSuite : IAsyncLifetime where TSubscription : class, IWebhookSubscription { + public abstract class WebhookManagementTestSuite : IAsyncLifetime + where TSubscription : class, IWebhookSubscription + where TKey : notnull { protected WebhookManagementTestSuite(ITestOutputHelper testOutput) { TestOutput = testOutput; } @@ -42,13 +44,13 @@ protected TSubscription GenerateSubscription(Func? conditio } } - protected WebhookSubscriptionManager Manager - => Scope!.ServiceProvider.GetRequiredService>(); + protected WebhookSubscriptionManager Manager + => Scope!.ServiceProvider.GetRequiredService>(); - protected IWebhookSubscriptionRepository Repository - => Scope!.ServiceProvider.GetRequiredService>(); + protected IWebhookSubscriptionRepository Repository + => Scope!.ServiceProvider.GetRequiredService>(); - protected virtual object GenerateSubscriptionKey() => Guid.NewGuid(); + protected abstract TKey GenerateSubscriptionKey(); private IServiceProvider BuildServices() { var services = new ServiceCollection(); @@ -61,22 +63,22 @@ private IServiceProvider BuildServices() { } protected virtual void ConfigureWebhooks(IServiceCollection services) { - services.AddWebhookSubscriptions(options => { + services.AddWebhookSubscriptions(options => { ConfigureWebhookStorage(options); }); } - protected abstract void ConfigureWebhookStorage(WebhookSubscriptionBuilder options); + protected abstract void ConfigureWebhookStorage(WebhookSubscriptionBuilder options); protected virtual void ConfigureServices(IServiceCollection services) { ConfigureWebhooks(services); } - protected virtual async Task SeedAsync(IRepository repository) { + protected virtual async Task SeedAsync(IRepository repository) { await repository.AddRangeAsync(Subscriptions!); } - protected virtual async Task ClearAsync(IRepository repository) { + protected virtual async Task ClearAsync(IRepository repository) { await repository.RemoveRangeAsync(Subscriptions!); } @@ -117,7 +119,7 @@ public async Task AddSubscription() { Assert.NotNull(subscription.SubscriptionId); var key = Repository.GetEntityKey(subscription); - var found = await Repository.FindByKeyAsync(key!); + var found = await Repository.FindAsync(key!); Assert.NotNull(found); Assert.Equal(subscription.SubscriptionId, found.SubscriptionId); @@ -162,7 +164,7 @@ public async Task SetNewDestinationUrl() { Assert.False(result.IsError()); var key = Repository.GetEntityKey(subscription); - var updated = await Repository.FindByKeyAsync(key!); + var updated = await Repository.FindAsync(key!); Assert.NotNull(updated); Assert.Equal("http://new.example.com", updated.DestinationUrl); @@ -212,7 +214,7 @@ public async Task SetEventTypes_AddNew() { Assert.False(result.IsError()); var key = Repository.GetEntityKey(subscription); - var updated = await Repository.FindByKeyAsync(key!); + var updated = await Repository.FindAsync(key!); Assert.NotNull(updated); Assert.Contains("user.created", updated.EventTypes); @@ -231,7 +233,7 @@ public async Task SetEventTypes_Remove() { Assert.False(result.IsError()); var key = Repository.GetEntityKey(subscription); - var updated = await Repository.FindByKeyAsync(key!); + var updated = await Repository.FindAsync(key!); Assert.NotNull(updated); Assert.DoesNotContain(eventTypeToRemove, updated.EventTypes); @@ -259,7 +261,7 @@ public async Task SetNewSecret() { Assert.False(result.IsError()); var key = Repository.GetEntityKey(subscription); - var updated = await Repository.FindByKeyAsync(key!); + var updated = await Repository.FindAsync(key!); Assert.NotNull(updated); Assert.Equal(secret, updated.Secret); @@ -285,7 +287,7 @@ public async Task RemoveSecret() { Assert.False(result.IsError()); var key = Repository.GetEntityKey(subscription); - var updated = await Repository.FindByKeyAsync(key!); + var updated = await Repository.FindAsync(key!); Assert.NotNull(updated); Assert.Null(updated.Secret); @@ -298,7 +300,7 @@ public async Task FindExistingSubscription() { var key = Repository.GetEntityKey(subscription); Assert.NotNull(key); - var found = await Manager.FindByKeyAsync(key); + var found = await Manager.FindAsync(key); Assert.NotNull(found); Assert.Equal(subscription.SubscriptionId, found.SubscriptionId); @@ -314,7 +316,7 @@ public async Task FindExistingSubscription() { public async Task FindNotExistingSubscription() { var key = GenerateSubscriptionKey(); - var found = await Manager.FindByKeyAsync(key); + var found = await Manager.FindAsync(key); Assert.Null(found); } @@ -325,7 +327,7 @@ public async Task RemoveExistingSubscription() { var key = Repository.GetEntityKey(subscription); Assert.NotNull(key); - var toRemove = await Repository.FindByKeyAsync(key); + var toRemove = await Repository.FindAsync(key); Assert.NotNull(toRemove); @@ -333,7 +335,7 @@ public async Task RemoveExistingSubscription() { Assert.True(result.IsSuccess()); - var found = await Repository.FindByKeyAsync(key); + var found = await Repository.FindAsync(key); Assert.Null(found); } @@ -360,7 +362,7 @@ public async Task ActivateSubscription() { Assert.True(result.IsSuccess()); - var updated = await Repository.FindByKeyAsync(key); + var updated = await Repository.FindAsync(key); Assert.NotNull(updated); Assert.Equal(WebhookSubscriptionStatus.Active, updated.Status); @@ -387,7 +389,7 @@ public async Task SuspendSubscription() { Assert.True(result.IsSuccess()); - var found = await Repository.FindByKeyAsync(key); + var found = await Repository.FindAsync(key); Assert.NotNull(found); Assert.Equal(WebhookSubscriptionStatus.Suspended, found.Status); @@ -406,7 +408,7 @@ public async Task AddNewHeaders() { Assert.True(result.IsSuccess()); var key = Repository.GetEntityKey(subscription); - var updated = await Repository.FindByKeyAsync(key!); + var updated = await Repository.FindAsync(key!); Assert.NotNull(updated); @@ -444,7 +446,7 @@ public async Task AddNewProperties() { Assert.False(result.IsNotModified()); var key = Repository.GetEntityKey(subscription); - var updated = await Repository.FindByKeyAsync(key!); + var updated = await Repository.FindAsync(key!); Assert.NotNull(updated); Assert.NotNull(updated.Properties); diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Deveel.Webhooks.MongoDb.XUnit.csproj b/test/Deveel.Webhooks.MongoDb.XUnit/Deveel.Webhooks.MongoDb.XUnit.csproj index 756c778..e450b48 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Deveel.Webhooks.MongoDb.XUnit.csproj +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Deveel.Webhooks.MongoDb.XUnit.csproj @@ -18,4 +18,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbConfigurationTests.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbConfigurationTests.cs index 4357e5d..e86b39c 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbConfigurationTests.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbConfigurationTests.cs @@ -5,6 +5,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using MongoDB.Bson; + using MongoFramework; namespace Deveel.Webhooks { @@ -12,7 +14,7 @@ public static class MongoDbConfigurationTests { [Fact] public static void WithConnection() { var provider = new ServiceCollection() - .AddWebhookSubscriptions(webhooks => + .AddWebhookSubscriptions(webhooks => webhooks.UseMongoDb("mongodb://127.0.0.1:2709/my_db")) .BuildServiceProvider(); @@ -34,7 +36,7 @@ public static void ConfigurationPattern_ExternalConnectionString() { var provider = new ServiceCollection() .AddSingleton(config.Build()) - .AddWebhookSubscriptions(webhooks => { + .AddWebhookSubscriptions(webhooks => { webhooks.UseMongoDb(mongo => mongo.WithConnectionStringName("MongoDb")); }) .BuildServiceProvider(); @@ -53,14 +55,14 @@ public static void ConfigurationPattern_ExternalConnectionString() { [Fact] public static void ConfigureCustomStorage() { var provider = new ServiceCollection() - .AddWebhookSubscriptions(webhook => webhook + .AddWebhookSubscriptions(webhook => webhook .UseMongoDb(builder => { builder.WithConnectionString("mongodb://127.0.0.1:2709/my_db"); builder.UseSubscriptionRepository(); })) .BuildServiceProvider(); - var store = provider.GetService>(); + var store = provider.GetService>(); Assert.NotNull(store); Assert.IsType(store); } diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbDeliveryResultStoreTests.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbDeliveryResultStoreTests.cs index a6841db..e9c8023 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbDeliveryResultStoreTests.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbDeliveryResultStoreTests.cs @@ -51,8 +51,8 @@ public MongoDbDeliveryResultStoreTests(MongoTestDatabase mongo, ITestOutputHelpe results = new List(); } - private IWebhookDeliveryResultRepository Store - => Services.GetRequiredService>(); + private IWebhookDeliveryResultRepository Repository + => ScopeServices.GetRequiredService>(); public override async Task InitializeAsync() { await base.InitializeAsync(); @@ -67,7 +67,7 @@ public override async Task InitializeAsync() { } private Task CreateAttemptAsync(MongoWebhookDeliveryResult attempt) { - return Store.AddAsync(attempt, default); + return Repository.AddAsync(attempt, default); } private MongoWebhookDeliveryResult NextRandom() @@ -77,7 +77,7 @@ private MongoWebhookDeliveryResult NextRandom() public async Task AddNewResult() { var result = faker.Generate(); - await Store.AddAsync(result); + await Repository.AddAsync(result); Assert.NotEqual(ObjectId.Empty, result.Id); @@ -88,7 +88,7 @@ public async Task AddNewResult() { public async Task GetExistingResult() { var result = NextRandom(); - var found = await Store.FindByKeyAsync(result.Id); + var found = await Repository.FindAsync(result.Id); Assert.NotNull(found); Assert.Equal(result.Id, found.Id); @@ -110,7 +110,7 @@ public async Task GetExistingResult() { public async Task GetNotExistingResult() { var resultId = ObjectId.GenerateNewId(); - var found = await Store.FindByKeyAsync(resultId); + var found = await Repository.FindAsync(resultId); Assert.Null(found); } @@ -119,11 +119,11 @@ public async Task GetNotExistingResult() { public async Task RemoveExistingResult() { var result = NextRandom(); - var removed = await Store.RemoveAsync(result); + var removed = await Repository.RemoveAsync(result); Assert.True(removed); - var found = await Store.FindByKeyAsync(result.Id); + var found = await Repository.FindAsync(result.Id); Assert.Null(found); } @@ -132,16 +132,16 @@ public async Task RemoveExistingResult() { public async Task RemoveNotExistingResult() { var result = faker.Generate(); - var removed = await Store.RemoveAsync(result); + var removed = await Repository.RemoveAsync(result); Assert.False(removed); - var found = await Store.FindByKeyAsync(result.Id); + var found = await Repository.FindAsync(result.Id); Assert.Null(found); } [Fact] public async Task CountAll() { - var count = await Store.CountAllAsync(); + var count = await Repository.CountAllAsync(); Assert.Equal(results.Count, count); } @@ -150,7 +150,7 @@ public async Task CountAll() { public async Task GetByWebhookId() { var result = NextRandom(); - var found = await Store.FindByWebhookIdAsync(result.Webhook.WebhookId, default); + var found = await Repository.FindByWebhookIdAsync(result.Webhook.WebhookId, default); Assert.NotNull(found); Assert.Equal(result.Id, found.Id); diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbWebhookTestBase.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbWebhookTestBase.cs index 14d38b7..b125e54 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbWebhookTestBase.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDbWebhookTestBase.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using MongoDB.Bson; using MongoDB.Driver; using Xunit.Abstractions; @@ -25,6 +26,8 @@ protected MongoDbWebhookTestBase(MongoTestDatabase mongo, ITestOutputHelper outp protected IServiceScope Scope { get; } + protected IServiceProvider ScopeServices => Scope.ServiceProvider; + protected string ConnectionString => mongo.ConnectionString; protected MongoClient Client { get; } @@ -43,7 +46,7 @@ public virtual async Task DisposeAsync() { private IServiceProvider BuildServiceProvider(ITestOutputHelper outputHelper) { var services = new ServiceCollection() - .AddWebhookSubscriptions(buidler => ConfigureWebhookService(buidler)) + .AddWebhookSubscriptions(buidler => ConfigureWebhookService(buidler)) .AddHttpCallback(OnRequestAsync) .AddLogging(logging => logging.AddXUnit(outputHelper)); @@ -56,7 +59,7 @@ protected virtual Task OnRequestAsync(HttpRequestMessage ht return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)); } - protected virtual void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { + protected virtual void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { builder.UseMongoDb(options => { options.WithConnectionString($"{ConnectionString}webhooks"); }); diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDeliveryResultLoggingTests.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDeliveryResultLoggingTests.cs index bb227ad..b20324d 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDeliveryResultLoggingTests.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoDeliveryResultLoggingTests.cs @@ -4,6 +4,8 @@ using Microsoft.Extensions.DependencyInjection; +using MongoDB.Bson; + using Xunit.Abstractions; namespace Deveel.Webhooks { @@ -15,8 +17,8 @@ public MongoDeliveryResultLoggingTests(MongoTestDatabase mongo, ITestOutputHelpe this.mongo = mongo; } - private IRepositoryProvider RepositoryProvider - => Scope!.ServiceProvider.GetRequiredService>(); + private IRepositoryProvider RepositoryProvider + => Scope!.ServiceProvider.GetRequiredService>(); protected override void ConfigureService(IServiceCollection services) { services.AddSingleton(_ => { @@ -26,6 +28,8 @@ protected override void ConfigureService(IServiceCollection services) { }; }); + services.AddRepositoryTenantResolver(); + services.AddMultiTenant() .WithInMemoryStore(store => { store.Tenants.Add(new TenantInfo { @@ -45,7 +49,7 @@ protected override void ConfigureService(IServiceCollection services) { services.AddSingleton, DefaultMongoWebhookConverter>(); services.AddMongoDbContext((tenant, builder) => builder.UseConnection(tenant!.ConnectionString!)); - services.AddRepositoryProvider>(); + services.AddRepositoryProvider(); services.AddScoped, MongoDbWebhookDeliveryResultLogger>(); } diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoSubsctiptionResolverTests.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoSubsctiptionResolverTests.cs index 3296fe1..456c18f 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoSubsctiptionResolverTests.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoSubsctiptionResolverTests.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; +using MongoDB.Bson; using MongoDB.Driver; using Xunit.Abstractions; @@ -14,7 +15,8 @@ public MongoSubsctiptionResolverTests(MongoTestDatabase mongo, ITestOutputHelper protected IList Subscriptions { get; private set; } - protected IRepository Repository => Scope.ServiceProvider.GetRequiredService>(); + protected IRepository Repository + => Scope.ServiceProvider.GetRequiredService>(); public IWebhookSubscriptionResolver Resolver => Scope.ServiceProvider.GetRequiredService(); diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoTenantWebhookManagementTests.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoTenantWebhookManagementTests.cs index 1dc7ad8..2596d22 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoTenantWebhookManagementTests.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoTenantWebhookManagementTests.cs @@ -11,7 +11,7 @@ namespace Deveel.Webhooks { [Collection(nameof(MongoWebhookManagementTestCollection))] - public class MongoTenantWebhookManagementTests : WebhookManagementTestSuite { + public class MongoTenantWebhookManagementTests : WebhookManagementTestSuite { private readonly MongoTestDatabase mongo; private readonly Faker faker; private readonly Faker otherFaker; @@ -31,7 +31,7 @@ public MongoTenantWebhookManagementTests(MongoTestDatabase mongo, ITestOutputHel protected override Faker Faker => faker; - protected override object GenerateSubscriptionKey() => ObjectId.GenerateNewId(); + protected override ObjectId GenerateSubscriptionKey() => ObjectId.GenerateNewId(); protected IReadOnlyList OtherSubscriptions { get; } @@ -46,7 +46,7 @@ protected override void ConfigureServices(IServiceCollection services) { base.ConfigureServices(services); } - protected override void ConfigureWebhookStorage(WebhookSubscriptionBuilder options) { + protected override void ConfigureWebhookStorage(WebhookSubscriptionBuilder options) { options.UseMongoDb(db => db.UseMultiTenant()); } diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoWebhooksManagementTests.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoWebhooksManagementTests.cs index e06dd94..0d7be79 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoWebhooksManagementTests.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MongoWebhooksManagementTests.cs @@ -7,7 +7,7 @@ namespace Deveel.Webhooks { [Collection(nameof(MongoWebhookManagementTestCollection))] - public class MongoWebhooksManagementTests : WebhookManagementTestSuite { + public class MongoWebhooksManagementTests : WebhookManagementTestSuite { private readonly MongoTestDatabase mongo; private readonly Faker faker; @@ -24,9 +24,9 @@ public MongoWebhooksManagementTests(MongoTestDatabase mongo, ITestOutputHelper t protected override Faker Faker => faker; - protected override object GenerateSubscriptionKey() => ObjectId.GenerateNewId(); + protected override ObjectId GenerateSubscriptionKey() => ObjectId.GenerateNewId(); - protected override void ConfigureWebhookStorage(WebhookSubscriptionBuilder options) { + protected override void ConfigureWebhookStorage(WebhookSubscriptionBuilder options) { options.UseMongoDb(db => db.WithConnectionString(ConnectionString)); } diff --git a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MultiTenantWebhookDeliveryResultLoggingTests.cs b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MultiTenantWebhookDeliveryResultLoggingTests.cs index 706f28e..2e641b0 100644 --- a/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MultiTenantWebhookDeliveryResultLoggingTests.cs +++ b/test/Deveel.Webhooks.MongoDb.XUnit/Webhooks/MultiTenantWebhookDeliveryResultLoggingTests.cs @@ -7,6 +7,8 @@ using Microsoft.Extensions.DependencyInjection; +using MongoDB.Bson; + using Xunit.Abstractions; namespace Deveel.Webhooks { @@ -16,8 +18,8 @@ public class MultiTenantWebhookDeliveryResultLoggingTests : MongoDbWebhookTestBa private readonly string tenantId = Guid.NewGuid().ToString(); - private IWebhookSubscriptionRepositoryProvider webhookStoreProvider; - private IWebhookDeliveryResultRepositoryProvider deliveryResultStoreProvider; + private IWebhookSubscriptionRepositoryProvider webhookStoreProvider; + private IWebhookDeliveryResultRepositoryProvider deliveryResultStoreProvider; private ITenantWebhookNotifier notifier; private Webhook? lastWebhook; @@ -25,8 +27,8 @@ public class MultiTenantWebhookDeliveryResultLoggingTests : MongoDbWebhookTestBa public MultiTenantWebhookDeliveryResultLoggingTests(MongoTestDatabase mongo, ITestOutputHelper outputHelper) : base(mongo, outputHelper) { - webhookStoreProvider = Services.GetRequiredService>(); - deliveryResultStoreProvider = Services.GetRequiredService>(); + webhookStoreProvider = Services.GetRequiredService>(); + deliveryResultStoreProvider = Services.GetRequiredService>(); notifier = Services.GetRequiredService>(); } @@ -55,7 +57,7 @@ protected override void ConfigureServices(IServiceCollection services) { base.ConfigureServices(services); } - protected override void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { + protected override void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { builder.UseSubscriptionManager() .UseMongoDb(options => options.UseMultiTenant()); } diff --git a/test/Deveel.Webhooks.Receiver.Facebook.XUnit/Deveel.Webhooks.Receiver.Facebook.XUnit.csproj b/test/Deveel.Webhooks.Receiver.Facebook.XUnit/Deveel.Webhooks.Receiver.Facebook.XUnit.csproj index 0897945..c7e3420 100644 --- a/test/Deveel.Webhooks.Receiver.Facebook.XUnit/Deveel.Webhooks.Receiver.Facebook.XUnit.csproj +++ b/test/Deveel.Webhooks.Receiver.Facebook.XUnit/Deveel.Webhooks.Receiver.Facebook.XUnit.csproj @@ -12,4 +12,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + \ No newline at end of file diff --git a/test/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit.csproj b/test/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit.csproj index c9226e3..7d4a00b 100644 --- a/test/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit.csproj +++ b/test/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit/Deveel.Webhooks.Receiver.NewtonsoftJson.XUnit.csproj @@ -8,4 +8,16 @@ + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/test/Deveel.Webhooks.Receiver.SendGrid.XUnit/Deveel.Webhooks.Receiver.SendGrid.XUnit.csproj b/test/Deveel.Webhooks.Receiver.SendGrid.XUnit/Deveel.Webhooks.Receiver.SendGrid.XUnit.csproj index 7ffb1e7..f1cab9f 100644 --- a/test/Deveel.Webhooks.Receiver.SendGrid.XUnit/Deveel.Webhooks.Receiver.SendGrid.XUnit.csproj +++ b/test/Deveel.Webhooks.Receiver.SendGrid.XUnit/Deveel.Webhooks.Receiver.SendGrid.XUnit.csproj @@ -13,4 +13,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/Deveel.Webhooks.Receiver.Tests/Deveel.Webhooks.Receiver.Tests.csproj b/test/Deveel.Webhooks.Receiver.Tests/Deveel.Webhooks.Receiver.Tests.csproj index 231623b..c0286f7 100644 --- a/test/Deveel.Webhooks.Receiver.Tests/Deveel.Webhooks.Receiver.Tests.csproj +++ b/test/Deveel.Webhooks.Receiver.Tests/Deveel.Webhooks.Receiver.Tests.csproj @@ -8,6 +8,7 @@ + diff --git a/test/Deveel.Webhooks.Receiver.Twilio.XUnit/Deveel.Webhooks.Receiver.Twilio.XUnit.csproj b/test/Deveel.Webhooks.Receiver.Twilio.XUnit/Deveel.Webhooks.Receiver.Twilio.XUnit.csproj index 4705384..c253727 100644 --- a/test/Deveel.Webhooks.Receiver.Twilio.XUnit/Deveel.Webhooks.Receiver.Twilio.XUnit.csproj +++ b/test/Deveel.Webhooks.Receiver.Twilio.XUnit/Deveel.Webhooks.Receiver.Twilio.XUnit.csproj @@ -17,4 +17,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/Deveel.Webhooks.Receiver.XUnit/Deveel.Webhooks.Receiver.XUnit.csproj b/test/Deveel.Webhooks.Receiver.XUnit/Deveel.Webhooks.Receiver.XUnit.csproj index ac80424..c7fe15a 100644 --- a/test/Deveel.Webhooks.Receiver.XUnit/Deveel.Webhooks.Receiver.XUnit.csproj +++ b/test/Deveel.Webhooks.Receiver.XUnit/Deveel.Webhooks.Receiver.XUnit.csproj @@ -21,6 +21,13 @@ + + + + + + + @@ -28,4 +35,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/Deveel.Webhooks.Sender.XUnit/Deveel.Webhooks.Sender.XUnit.csproj b/test/Deveel.Webhooks.Sender.XUnit/Deveel.Webhooks.Sender.XUnit.csproj index fea9bb6..0d01a44 100644 --- a/test/Deveel.Webhooks.Sender.XUnit/Deveel.Webhooks.Sender.XUnit.csproj +++ b/test/Deveel.Webhooks.Sender.XUnit/Deveel.Webhooks.Sender.XUnit.csproj @@ -18,4 +18,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/Deveel.Webhooks.Sender.XUnit/Webhooks/WebhookSenderTests.cs b/test/Deveel.Webhooks.Sender.XUnit/Webhooks/WebhookSenderTests.cs index 493fd1a..df84d4f 100644 --- a/test/Deveel.Webhooks.Sender.XUnit/Webhooks/WebhookSenderTests.cs +++ b/test/Deveel.Webhooks.Sender.XUnit/Webhooks/WebhookSenderTests.cs @@ -122,6 +122,9 @@ private IServiceProvider ConfigureServices(ITestOutputHelper outputHelper) { return new HttpResponseMessage(valid ? HttpStatusCode.OK : HttpStatusCode.Unauthorized); }); + mockHandler.Fallback.Respond(request => { + return new HttpResponseMessage(HttpStatusCode.NotFound); + }); var services = new ServiceCollection() .AddLogging(logging => logging.AddXUnit(outputHelper, options => options.Filter = (cat, level) => true) diff --git a/test/Deveel.Webhooks.TestHttpClient/Deveel.Webhooks.TestHttpClient.csproj b/test/Deveel.Webhooks.TestHttpClient/Deveel.Webhooks.TestHttpClient.csproj index 465bcd4..de78278 100644 --- a/test/Deveel.Webhooks.TestHttpClient/Deveel.Webhooks.TestHttpClient.csproj +++ b/test/Deveel.Webhooks.TestHttpClient/Deveel.Webhooks.TestHttpClient.csproj @@ -14,4 +14,9 @@ + + + + + diff --git a/test/Deveel.Webhooks.XUnit/Deveel.Webhooks.XUnit.csproj b/test/Deveel.Webhooks.XUnit/Deveel.Webhooks.XUnit.csproj index 04f295e..572cbe4 100644 --- a/test/Deveel.Webhooks.XUnit/Deveel.Webhooks.XUnit.csproj +++ b/test/Deveel.Webhooks.XUnit/Deveel.Webhooks.XUnit.csproj @@ -29,4 +29,16 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/Deveel.Webhooks.XUnit/Webhooks/WebhookServiceTestBase.cs b/test/Deveel.Webhooks.XUnit/Webhooks/WebhookServiceTestBase.cs index e0e90dc..1dcd01b 100644 --- a/test/Deveel.Webhooks.XUnit/Webhooks/WebhookServiceTestBase.cs +++ b/test/Deveel.Webhooks.XUnit/Webhooks/WebhookServiceTestBase.cs @@ -32,7 +32,7 @@ protected WebhookServiceTestBase(ITestOutputHelper outputHelper) { private IServiceProvider BuildServiceProvider(ITestOutputHelper outputHelper) { var services = new ServiceCollection() - .AddWebhookSubscriptions(buidler => ConfigureWebhookService(buidler)) + .AddWebhookSubscriptions(buidler => ConfigureWebhookService(buidler)) .AddHttpCallback(OnRequestAsync) .AddLogging(logging => logging.AddXUnit(outputHelper).SetMinimumLevel(LogLevel.Trace)); @@ -45,7 +45,7 @@ protected virtual Task OnRequestAsync(HttpRequestMessage ht return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)); } - protected virtual void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { + protected virtual void ConfigureWebhookService(WebhookSubscriptionBuilder builder) { } protected virtual void ConfigureServices(IServiceCollection services) { diff --git a/test/Directory.Build.props b/test/Directory.Build.props index cc055fe..7d28dca 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,6 +1,6 @@ - net6.0;net7.0 + net6.0;net7.0;net8.0 enable enable Deveel