diff --git a/Directory.Packages.props b/Directory.Packages.props index 7005b24..989fd3f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -28,6 +28,8 @@ + + diff --git a/src/Apps/Basket.Api/packages.lock.json b/src/Apps/Basket.Api/packages.lock.json index 27c383c..5e5e03a 100644 --- a/src/Apps/Basket.Api/packages.lock.json +++ b/src/Apps/Basket.Api/packages.lock.json @@ -158,6 +158,15 @@ "resolved": "6.0.3", "contentHash": "/FkS66n3wJaUR+Grkg+dMMIyrfmfkEybNoyOhdBMURxavPx6Q1Kn7NY5Ho41s975gpXA9Pnw7WRJbxwICLFgbw==" }, + "Microsoft.Extensions.Compliance.Abstractions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "WBPhQCz84/PFR5vm6lVPOYh4e7lcIQ2EyhYl84hVoZHC1vtvVAZsb4htEVx1LEPkLIiwnIdiLSzXxqS7+hkkDA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4" + } + }, "Microsoft.Extensions.Configuration.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -237,8 +246,8 @@ }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "cjWrLkJXK0rs4zofsK4bSdg+jhDLTaxrkXu4gS6Y7MAlCvRyNNgwY/lJi5RDlQOnSZweHqoyvgvbdvQsRIW+hg==" + "resolved": "8.0.1", + "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" }, "Microsoft.Extensions.Diagnostics": { "type": "Transitive", @@ -321,10 +330,10 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "arDBqTgFCyS0EvRV7O3MZturChstm50OJ0y9bDJvAcmEPJm0FFpFyjU/JLYyStNGGey081DvnQYlncNX5SJJGA==", + "resolved": "8.0.1", + "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" } }, "Microsoft.Extensions.Logging.Configuration": { @@ -390,10 +399,15 @@ "System.Text.Json": "8.0.0" } }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "8.0.4", + "contentHash": "6FPHZ6lxtsrlFKE1LeHEco0BxevHSDdxngh37GxwGqiHm8zQz78ttM2OIevqQ8IAvtB01+5xEWBcYsjvSnhhoQ==" + }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JOVOfqpnqlVLUzINQ2fox8evY2SKLYJ3BV8QDe/Jyp21u1T7r45x/R/5QdteURMR5r01GxeJSBBUOCOyaNXA3g==", + "resolved": "8.0.2", + "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", "dependencies": { "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", "Microsoft.Extensions.Primitives": "8.0.0" @@ -950,6 +964,7 @@ "EasyNetQ.Serialization.SystemTextJson": "[7.8.0, )", "Microsoft.Extensions.Configuration": "[8.0.0, )", "Microsoft.Extensions.Hosting": "[8.0.0, )", + "Microsoft.Extensions.Telemetry.Abstractions": "[8.4.0, )", "OneOf": "[3.0.263, )", "OneOf.SourceGenerator": "[3.0.263, )", "System.Linq.Async": "[6.0.1, )", @@ -1077,6 +1092,18 @@ "Microsoft.Extensions.Options": "8.0.0" } }, + "Microsoft.Extensions.Telemetry.Abstractions": { + "type": "CentralTransitive", + "requested": "[8.4.0, )", + "resolved": "8.4.0", + "contentHash": "jiv/2aoe2zkI0Atl+WXChwy6CbjHByxUBLnF6OihMAPELgmKaSywLqcJo5VcbRYA0EGhmQJM/RaGVH3J2TAkxw==", + "dependencies": { + "Microsoft.Extensions.Compliance.Abstractions": "8.4.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4", + "Microsoft.Extensions.Options": "8.0.2" + } + }, "Newtonsoft.Json": { "type": "CentralTransitive", "requested": "[13.0.3, )", diff --git a/src/BuildingBlocks/Messaging/Logging/SubscriberLogger.cs b/src/BuildingBlocks/Messaging/Logging/SubscriberLogger.cs index 240c46e..7358905 100644 --- a/src/BuildingBlocks/Messaging/Logging/SubscriberLogger.cs +++ b/src/BuildingBlocks/Messaging/Logging/SubscriberLogger.cs @@ -1,3 +1,5 @@ +using EasyNetQ; + using Microsoft.Extensions.Logging; namespace Messaging.Logging; @@ -9,7 +11,7 @@ internal static partial class SubscriberLogger Level = LogLevel.Error, Message = "Can't process message {Exchange} -> {RoutingKey} -> {Queue}")] public static partial void LogCantProcessMessage( - this ILogger logger, Exception exception, string exchange, string routingKey, string queue); + this ILogger logger, Exception exception, string exchange, string routingKey, string queue, [LogProperties(SkipNullProperties = true)]MessageProperties properties); [LoggerMessage( diff --git a/src/BuildingBlocks/Messaging/Messaging.csproj b/src/BuildingBlocks/Messaging/Messaging.csproj index c180c19..1cd83c8 100644 --- a/src/BuildingBlocks/Messaging/Messaging.csproj +++ b/src/BuildingBlocks/Messaging/Messaging.csproj @@ -15,6 +15,7 @@ + diff --git a/src/BuildingBlocks/Messaging/RabbitMq/Consumer/RabbitMqMessageConsumer.cs b/src/BuildingBlocks/Messaging/RabbitMq/Consumer/RabbitMqMessageConsumer.cs index 59d036e..6836665 100644 --- a/src/BuildingBlocks/Messaging/RabbitMq/Consumer/RabbitMqMessageConsumer.cs +++ b/src/BuildingBlocks/Messaging/RabbitMq/Consumer/RabbitMqMessageConsumer.cs @@ -55,9 +55,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) var queue = await _advancedBus.QueueDeclareAsync(_subscriptionConfiguration.Queue, configuration => { configuration.AsDurable(true); - configuration.WithExpires(TimeSpan.FromDays(5)); configuration.WithMessageTtl(TimeSpan.FromHours(5)); - configuration.WithMaxLength(1000); + configuration.WithMaxLength(10000); }, stoppingToken); _ = await _advancedBus.BindAsync(exchange, queue, _subscriptionConfiguration.Topic, cancellationToken: stoppingToken); @@ -74,6 +73,9 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) activity.SetTag("messaging.rabbitmq.routing_key", info.RoutingKey); activity.SetTag("messaging.exchange", info.Exchange); activity.SetTag("messaging.destination", info.Queue); + activity.SetTag("messaging.timestamp", properties.Timestamp); + activity.SetTag("messaging.message_id", properties.MessageId); + activity.SetTag("messaging.message_type", properties.Type); activity.SetTag("messaging.system", "rabbitmq"); activity.SetTag("messaging.destination_kind", "queue"); activity.SetTag("messaging.protocol", "AMQP"); @@ -91,7 +93,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) var result = await subscriber.Handle(message, ct); if (!result.IsSuccess) { - logger.LogCantProcessMessage(result.ErrorValue, info.Exchange, info.RoutingKey, info.Queue); + logger.LogCantProcessMessage(result.ErrorValue, info.Exchange, info.RoutingKey, info.Queue, properties); activity?.RecordException(result.ErrorValue); return _subscriptionConfiguration.AckStrategy; } @@ -100,7 +102,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } catch (Exception exc) { - logger.LogCantProcessMessage(exc, info.Exchange, info.RoutingKey, info.Queue); + logger.LogCantProcessMessage(exc, info.Exchange, info.RoutingKey, info.Queue, properties); activity?.RecordException(exc); return _subscriptionConfiguration.AckStrategy; } diff --git a/src/BuildingBlocks/Messaging/packages.lock.json b/src/BuildingBlocks/Messaging/packages.lock.json index e649b69..c0c004e 100644 --- a/src/BuildingBlocks/Messaging/packages.lock.json +++ b/src/BuildingBlocks/Messaging/packages.lock.json @@ -72,6 +72,18 @@ "Microsoft.Extensions.Options": "8.0.0" } }, + "Microsoft.Extensions.Telemetry.Abstractions": { + "type": "Direct", + "requested": "[8.4.0, )", + "resolved": "8.4.0", + "contentHash": "jiv/2aoe2zkI0Atl+WXChwy6CbjHByxUBLnF6OihMAPELgmKaSywLqcJo5VcbRYA0EGhmQJM/RaGVH3J2TAkxw==", + "dependencies": { + "Microsoft.Extensions.Compliance.Abstractions": "8.4.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4", + "Microsoft.Extensions.Options": "8.0.2" + } + }, "OneOf": { "type": "Direct", "requested": "[3.0.263, )", @@ -136,6 +148,15 @@ "resolved": "6.0.0", "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==" }, + "Microsoft.Extensions.Compliance.Abstractions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "WBPhQCz84/PFR5vm6lVPOYh4e7lcIQ2EyhYl84hVoZHC1vtvVAZsb4htEVx1LEPkLIiwnIdiLSzXxqS7+hkkDA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4" + } + }, "Microsoft.Extensions.Configuration.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -215,8 +236,8 @@ }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "cjWrLkJXK0rs4zofsK4bSdg+jhDLTaxrkXu4gS6Y7MAlCvRyNNgwY/lJi5RDlQOnSZweHqoyvgvbdvQsRIW+hg==" + "resolved": "8.0.1", + "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" }, "Microsoft.Extensions.Diagnostics": { "type": "Transitive", @@ -275,10 +296,10 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "arDBqTgFCyS0EvRV7O3MZturChstm50OJ0y9bDJvAcmEPJm0FFpFyjU/JLYyStNGGey081DvnQYlncNX5SJJGA==", + "resolved": "8.0.1", + "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" } }, "Microsoft.Extensions.Logging.Configuration": { @@ -344,10 +365,15 @@ "System.Text.Json": "8.0.0" } }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "8.0.4", + "contentHash": "6FPHZ6lxtsrlFKE1LeHEco0BxevHSDdxngh37GxwGqiHm8zQz78ttM2OIevqQ8IAvtB01+5xEWBcYsjvSnhhoQ==" + }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JOVOfqpnqlVLUzINQ2fox8evY2SKLYJ3BV8QDe/Jyp21u1T7r45x/R/5QdteURMR5r01GxeJSBBUOCOyaNXA3g==", + "resolved": "8.0.2", + "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", "dependencies": { "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", "Microsoft.Extensions.Primitives": "8.0.0" diff --git a/src/Modules/Basket/packages.lock.json b/src/Modules/Basket/packages.lock.json index c5bb7c1..dc949e3 100644 --- a/src/Modules/Basket/packages.lock.json +++ b/src/Modules/Basket/packages.lock.json @@ -137,6 +137,15 @@ "resolved": "6.0.0", "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==" }, + "Microsoft.Extensions.Compliance.Abstractions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "WBPhQCz84/PFR5vm6lVPOYh4e7lcIQ2EyhYl84hVoZHC1vtvVAZsb4htEVx1LEPkLIiwnIdiLSzXxqS7+hkkDA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4" + } + }, "Microsoft.Extensions.Configuration.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -216,8 +225,8 @@ }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "cjWrLkJXK0rs4zofsK4bSdg+jhDLTaxrkXu4gS6Y7MAlCvRyNNgwY/lJi5RDlQOnSZweHqoyvgvbdvQsRIW+hg==" + "resolved": "8.0.1", + "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" }, "Microsoft.Extensions.Diagnostics": { "type": "Transitive", @@ -276,10 +285,10 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "arDBqTgFCyS0EvRV7O3MZturChstm50OJ0y9bDJvAcmEPJm0FFpFyjU/JLYyStNGGey081DvnQYlncNX5SJJGA==", + "resolved": "8.0.1", + "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" } }, "Microsoft.Extensions.Logging.Configuration": { @@ -345,10 +354,15 @@ "System.Text.Json": "8.0.0" } }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "8.0.4", + "contentHash": "6FPHZ6lxtsrlFKE1LeHEco0BxevHSDdxngh37GxwGqiHm8zQz78ttM2OIevqQ8IAvtB01+5xEWBcYsjvSnhhoQ==" + }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JOVOfqpnqlVLUzINQ2fox8evY2SKLYJ3BV8QDe/Jyp21u1T7r45x/R/5QdteURMR5r01GxeJSBBUOCOyaNXA3g==", + "resolved": "8.0.2", + "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", "dependencies": { "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", "Microsoft.Extensions.Primitives": "8.0.0" @@ -457,6 +471,7 @@ "EasyNetQ.Serialization.SystemTextJson": "[7.8.0, )", "Microsoft.Extensions.Configuration": "[8.0.0, )", "Microsoft.Extensions.Hosting": "[8.0.0, )", + "Microsoft.Extensions.Telemetry.Abstractions": "[8.4.0, )", "OneOf": "[3.0.263, )", "OneOf.SourceGenerator": "[3.0.263, )", "System.Linq.Async": "[6.0.1, )", @@ -524,6 +539,18 @@ "Microsoft.Extensions.Options": "8.0.0" } }, + "Microsoft.Extensions.Telemetry.Abstractions": { + "type": "CentralTransitive", + "requested": "[8.4.0, )", + "resolved": "8.4.0", + "contentHash": "jiv/2aoe2zkI0Atl+WXChwy6CbjHByxUBLnF6OihMAPELgmKaSywLqcJo5VcbRYA0EGhmQJM/RaGVH3J2TAkxw==", + "dependencies": { + "Microsoft.Extensions.Compliance.Abstractions": "8.4.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4", + "Microsoft.Extensions.Options": "8.0.2" + } + }, "OpenTelemetry.Exporter.Console": { "type": "CentralTransitive", "requested": "[1.8.1, )", diff --git a/tests/BuildingBlocks/Messaging.Tests/packages.lock.json b/tests/BuildingBlocks/Messaging.Tests/packages.lock.json index 0ed0b86..9fa1501 100644 --- a/tests/BuildingBlocks/Messaging.Tests/packages.lock.json +++ b/tests/BuildingBlocks/Messaging.Tests/packages.lock.json @@ -208,6 +208,15 @@ "resolved": "17.9.0", "contentHash": "RGD37ZSrratfScYXm7M0HjvxMxZyWZL4jm+XgMZbkIY1UPgjUpbNA/t+WTGj/rC/0Hm9A3IrH3ywbKZkOCnoZA==" }, + "Microsoft.Extensions.Compliance.Abstractions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "WBPhQCz84/PFR5vm6lVPOYh4e7lcIQ2EyhYl84hVoZHC1vtvVAZsb4htEVx1LEPkLIiwnIdiLSzXxqS7+hkkDA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4" + } + }, "Microsoft.Extensions.Configuration.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -287,8 +296,8 @@ }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "cjWrLkJXK0rs4zofsK4bSdg+jhDLTaxrkXu4gS6Y7MAlCvRyNNgwY/lJi5RDlQOnSZweHqoyvgvbdvQsRIW+hg==" + "resolved": "8.0.1", + "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" }, "Microsoft.Extensions.Diagnostics": { "type": "Transitive", @@ -347,10 +356,10 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "arDBqTgFCyS0EvRV7O3MZturChstm50OJ0y9bDJvAcmEPJm0FFpFyjU/JLYyStNGGey081DvnQYlncNX5SJJGA==", + "resolved": "8.0.1", + "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" } }, "Microsoft.Extensions.Logging.Configuration": { @@ -416,10 +425,15 @@ "System.Text.Json": "8.0.0" } }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "8.0.4", + "contentHash": "6FPHZ6lxtsrlFKE1LeHEco0BxevHSDdxngh37GxwGqiHm8zQz78ttM2OIevqQ8IAvtB01+5xEWBcYsjvSnhhoQ==" + }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JOVOfqpnqlVLUzINQ2fox8evY2SKLYJ3BV8QDe/Jyp21u1T7r45x/R/5QdteURMR5r01GxeJSBBUOCOyaNXA3g==", + "resolved": "8.0.2", + "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", "dependencies": { "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", "Microsoft.Extensions.Primitives": "8.0.0" @@ -1524,6 +1538,7 @@ "EasyNetQ.Serialization.SystemTextJson": "[7.8.0, )", "Microsoft.Extensions.Configuration": "[8.0.0, )", "Microsoft.Extensions.Hosting": "[8.0.0, )", + "Microsoft.Extensions.Telemetry.Abstractions": "[8.4.0, )", "OneOf": "[3.0.263, )", "OneOf.SourceGenerator": "[3.0.263, )", "System.Linq.Async": "[6.0.1, )", @@ -1621,6 +1636,18 @@ "Microsoft.Extensions.Options": "8.0.0" } }, + "Microsoft.Extensions.Telemetry.Abstractions": { + "type": "CentralTransitive", + "requested": "[8.4.0, )", + "resolved": "8.4.0", + "contentHash": "jiv/2aoe2zkI0Atl+WXChwy6CbjHByxUBLnF6OihMAPELgmKaSywLqcJo5VcbRYA0EGhmQJM/RaGVH3J2TAkxw==", + "dependencies": { + "Microsoft.Extensions.Compliance.Abstractions": "8.4.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4", + "Microsoft.Extensions.Options": "8.0.2" + } + }, "Newtonsoft.Json": { "type": "CentralTransitive", "requested": "[13.0.3, )", diff --git a/tests/Modules/Basket.Tests/Basket.Tests.csproj b/tests/Modules/Basket.Tests/Basket.Tests.csproj index 3750527..98416f9 100644 --- a/tests/Modules/Basket.Tests/Basket.Tests.csproj +++ b/tests/Modules/Basket.Tests/Basket.Tests.csproj @@ -17,6 +17,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/tests/Modules/Basket.Tests/Core/RequestHandlers/AddItemToCustomerBasketHandlerTests.cs b/tests/Modules/Basket.Tests/Core/RequestHandlers/AddItemToCustomerBasketHandlerTests.cs index 4ac02db..f8bbd15 100644 --- a/tests/Modules/Basket.Tests/Core/RequestHandlers/AddItemToCustomerBasketHandlerTests.cs +++ b/tests/Modules/Basket.Tests/Core/RequestHandlers/AddItemToCustomerBasketHandlerTests.cs @@ -12,6 +12,8 @@ using Messaging.Abstraction; +using Microsoft.Extensions.Time.Testing; + using NSubstitute; using Shouldly; @@ -22,6 +24,7 @@ namespace Basket.Tests.Core.RequestHandlers; public sealed class AddItemToCustomerBasketHandlerTests { private readonly RedisFixture _redisFixture; + private readonly DateTimeOffset _dateTimeOffset = DateTimeOffset.Now; public AddItemToCustomerBasketHandlerTests(RedisFixture redisFixture) { @@ -37,7 +40,7 @@ public async Task TestAddItemToEmptyBasket_ShouldReturnBasketWithOneItem(Custome publisherMock.Publish(Arg.Any(), Arg.Any(), Arg.Any()).Returns(Result.UnitResult); var getCustomerBasket = new GetCustomerBasketHandler(_redisFixture.CustomerBasketReader); - var handler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock); + var handler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock, new FakeTimeProvider(_dateTimeOffset)); // Act await handler.Handle(new AddItemToCustomerBasket(customerId, basketItem), CancellationToken.None); var result = await getCustomerBasket.Handle(new GetCustomerBasket(customerId), CancellationToken.None); @@ -61,7 +64,7 @@ public async Task TestAddItemToNotEmptyBasket_ShouldReturnBasketWithTwoItems() var customerId = CustomerId.New(); var basketItem = new Product(ItemId.New(), new ItemQuantity(1)); var getCustomerBasket = new GetCustomerBasketHandler(_redisFixture.CustomerBasketReader); - var handler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock); + var handler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock, new FakeTimeProvider(_dateTimeOffset)); await handler.Handle(new AddItemToCustomerBasket(customerId, new Product(ItemId.New(), new ItemQuantity(2))), CancellationToken.None); // Act diff --git a/tests/Modules/Basket.Tests/Core/RequestHandlers/CheckoutCustomerBasketTests.cs b/tests/Modules/Basket.Tests/Core/RequestHandlers/CheckoutCustomerBasketTests.cs index 0779e57..1007b57 100644 --- a/tests/Modules/Basket.Tests/Core/RequestHandlers/CheckoutCustomerBasketTests.cs +++ b/tests/Modules/Basket.Tests/Core/RequestHandlers/CheckoutCustomerBasketTests.cs @@ -12,6 +12,8 @@ using Messaging.Abstraction; +using Microsoft.Extensions.Time.Testing; + using NSubstitute; using Shouldly; @@ -25,6 +27,7 @@ public sealed class CheckoutCustomerBasketTests : IClassFixture private readonly AddItemToCustomerBasketHandler _addItemToCustomerBasketHandler; private readonly CheckoutCustomerBasketHandler _checkoutCustomerBasketHandler; private readonly IMessagePublisher _messagePublisher; + private readonly DateTimeOffset _dateTimeOffset = DateTimeOffset.Now; public CheckoutCustomerBasketTests(RedisFixture redisFixture) { _messagePublisher = Substitute.For>(); @@ -32,7 +35,7 @@ public CheckoutCustomerBasketTests(RedisFixture redisFixture) _redisFixture = redisFixture; _getCustomerBasketHandler = new GetCustomerBasketHandler(_redisFixture.CustomerBasketReader); _addItemToCustomerBasketHandler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, - _redisFixture.CustomerBasketWriter, _messagePublisher); + _redisFixture.CustomerBasketWriter, _messagePublisher, new FakeTimeProvider(_dateTimeOffset)); _checkoutCustomerBasketHandler = new CheckoutCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter); } diff --git a/tests/Modules/Basket.Tests/Core/RequestHandlers/RemoveItemFromCustomerBasketRequestHandlerTEsts.cs b/tests/Modules/Basket.Tests/Core/RequestHandlers/RemoveItemFromCustomerBasketRequestHandlerTEsts.cs index f721b56..992f737 100644 --- a/tests/Modules/Basket.Tests/Core/RequestHandlers/RemoveItemFromCustomerBasketRequestHandlerTEsts.cs +++ b/tests/Modules/Basket.Tests/Core/RequestHandlers/RemoveItemFromCustomerBasketRequestHandlerTEsts.cs @@ -12,6 +12,8 @@ using Messaging.Abstraction; +using Microsoft.Extensions.Time.Testing; + using NSubstitute; using Shouldly; @@ -22,7 +24,8 @@ namespace Basket.Tests.Core.RequestHandlers; public class RemoveItemFromCustomerBasketRequestHandlerTests { private readonly RedisFixture _redisFixture; - + private readonly DateTimeOffset _dateTimeOffset = DateTimeOffset.Now; + public RemoveItemFromCustomerBasketRequestHandlerTests(RedisFixture redisFixture) { _redisFixture = redisFixture; @@ -41,8 +44,8 @@ public async Task TestAddItemToEmptyBasket_AndRemoveIt_ShouldReturnEmptyBasket(C var basketItem = new Product(ItemId.New(), new ItemQuantity(1)); var getCustomerBasket = new GetCustomerBasketHandler(_redisFixture.CustomerBasketReader); - var addhandler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock); - var removeHandler = new RemoveItemFromCustomerBasketRequestHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherRemovedMock); + var addhandler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock, new FakeTimeProvider(_dateTimeOffset)); + var removeHandler = new RemoveItemFromCustomerBasketRequestHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherRemovedMock, new FakeTimeProvider(_dateTimeOffset)); // Act await addhandler.Handle(new AddItemToCustomerBasket(customerId, basketItem), CancellationToken.None); await removeHandler.Handle(new RemoveItemFromCustomerBasket(customerId, basketItem), CancellationToken.None); @@ -67,8 +70,8 @@ public async Task TestAddItemToEmptyBasket_AndRemoveOne_ShouldReturnBasketWithTh var customerId = CustomerId.New(); var basketItem = new Product(ItemId.New(), new ItemQuantity(1)); var getCustomerBasket = new GetCustomerBasketHandler(_redisFixture.CustomerBasketReader); - var addhandler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock); - var removeHandler = new RemoveItemFromCustomerBasketRequestHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherRemovedMock); + var addhandler = new AddItemToCustomerBasketHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherMock, new FakeTimeProvider(_dateTimeOffset)); + var removeHandler = new RemoveItemFromCustomerBasketRequestHandler(_redisFixture.CustomerBasketReader, _redisFixture.CustomerBasketWriter, publisherRemovedMock, new FakeTimeProvider(_dateTimeOffset)); await addhandler.Handle(new AddItemToCustomerBasket(customerId, basketItem with { Quantity = new ItemQuantity(1) }), CancellationToken.None); // Act diff --git a/tests/Modules/Basket.Tests/packages.lock.json b/tests/Modules/Basket.Tests/packages.lock.json index 36a2239..39a51da 100644 --- a/tests/Modules/Basket.Tests/packages.lock.json +++ b/tests/Modules/Basket.Tests/packages.lock.json @@ -38,6 +38,12 @@ "System.Configuration.ConfigurationManager": "4.4.0" } }, + "Microsoft.Extensions.TimeProvider.Testing": { + "type": "Direct", + "requested": "[8.4.0, )", + "resolved": "8.4.0", + "contentHash": "xaXPM4dQe4oJ2gY82al9LtjLHcfXaD+N/lXw4qX02sd3mETQpV2h1jeJyRYxBJcbJHIvE0pR1gj5yz3/dbnMFw==" + }, "Microsoft.NET.Test.Sdk": { "type": "Direct", "requested": "[17.9.0, )", @@ -344,6 +350,15 @@ "resolved": "6.0.3", "contentHash": "/FkS66n3wJaUR+Grkg+dMMIyrfmfkEybNoyOhdBMURxavPx6Q1Kn7NY5Ho41s975gpXA9Pnw7WRJbxwICLFgbw==" }, + "Microsoft.Extensions.Compliance.Abstractions": { + "type": "Transitive", + "resolved": "8.4.0", + "contentHash": "WBPhQCz84/PFR5vm6lVPOYh4e7lcIQ2EyhYl84hVoZHC1vtvVAZsb4htEVx1LEPkLIiwnIdiLSzXxqS7+hkkDA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4" + } + }, "Microsoft.Extensions.Configuration.Abstractions": { "type": "Transitive", "resolved": "8.0.0", @@ -423,8 +438,8 @@ }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "cjWrLkJXK0rs4zofsK4bSdg+jhDLTaxrkXu4gS6Y7MAlCvRyNNgwY/lJi5RDlQOnSZweHqoyvgvbdvQsRIW+hg==" + "resolved": "8.0.1", + "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" }, "Microsoft.Extensions.DependencyModel": { "type": "Transitive", @@ -516,10 +531,10 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "arDBqTgFCyS0EvRV7O3MZturChstm50OJ0y9bDJvAcmEPJm0FFpFyjU/JLYyStNGGey081DvnQYlncNX5SJJGA==", + "resolved": "8.0.1", + "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" } }, "Microsoft.Extensions.Logging.Configuration": { @@ -585,10 +600,15 @@ "System.Text.Json": "8.0.0" } }, + "Microsoft.Extensions.ObjectPool": { + "type": "Transitive", + "resolved": "8.0.4", + "contentHash": "6FPHZ6lxtsrlFKE1LeHEco0BxevHSDdxngh37GxwGqiHm8zQz78ttM2OIevqQ8IAvtB01+5xEWBcYsjvSnhhoQ==" + }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JOVOfqpnqlVLUzINQ2fox8evY2SKLYJ3BV8QDe/Jyp21u1T7r45x/R/5QdteURMR5r01GxeJSBBUOCOyaNXA3g==", + "resolved": "8.0.2", + "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", "dependencies": { "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", "Microsoft.Extensions.Primitives": "8.0.0" @@ -1920,6 +1940,7 @@ "EasyNetQ.Serialization.SystemTextJson": "[7.8.0, )", "Microsoft.Extensions.Configuration": "[8.0.0, )", "Microsoft.Extensions.Hosting": "[8.0.0, )", + "Microsoft.Extensions.Telemetry.Abstractions": "[8.4.0, )", "OneOf": "[3.0.263, )", "OneOf.SourceGenerator": "[3.0.263, )", "System.Linq.Async": "[6.0.1, )", @@ -2078,6 +2099,18 @@ "Microsoft.Extensions.Options": "8.0.0" } }, + "Microsoft.Extensions.Telemetry.Abstractions": { + "type": "CentralTransitive", + "requested": "[8.4.0, )", + "resolved": "8.4.0", + "contentHash": "jiv/2aoe2zkI0Atl+WXChwy6CbjHByxUBLnF6OihMAPELgmKaSywLqcJo5VcbRYA0EGhmQJM/RaGVH3J2TAkxw==", + "dependencies": { + "Microsoft.Extensions.Compliance.Abstractions": "8.4.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.1", + "Microsoft.Extensions.ObjectPool": "8.0.4", + "Microsoft.Extensions.Options": "8.0.2" + } + }, "Newtonsoft.Json": { "type": "CentralTransitive", "requested": "[13.0.3, )",