From 5983c18b39b7aab4f36f3051c96b5615efc4cd45 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Fri, 24 Oct 2025 20:37:56 +0100 Subject: [PATCH 1/2] using latest shared nuget packages --- ...essagingService.BusinessLogic.Tests.csproj | 6 +- ...urationReaderConnectionStringRepository.cs | 91 ------------------- .../MessagingService.BusinessLogic.csproj | 16 ++-- .../IMessagingServiceClient.cs | 15 --- .../MessagingService.Client.csproj | 6 +- .../MessagingServiceClient.cs | 77 +--------------- ...essagingService.DataTransferObjects.csproj | 2 +- ...ssagingService.EmailAggregate.Tests.csproj | 6 +- ...ngService.EmailMessage.DomainEvents.csproj | 4 +- .../EmailAggregate.cs | 3 +- ...sagingService.EmailMessageAggregate.csproj | 4 +- ...gService.IntegrationTesting.Helpers.csproj | 2 +- .../Common/Setup.cs | 2 +- .../Email/SendEmail.feature.cs | 57 +++++++----- .../MessagingService.IntegrationTests.csproj | 22 ++--- .../SMS/SendSMS.feature.cs | 57 +++++++----- ...MessagingService.SMSAggregate.Tests.csproj | 4 +- ...gingService.SMSMessage.DomainEvents.csproj | 2 +- ...essagingService.SMSMessageAggregate.csproj | 2 +- .../SMSAggregate.cs | 3 +- MessagingService.Tests/ControllerTests.cs | 65 ------------- .../MessagingService.Tests.csproj | 8 +- .../Bootstrapper/RepositoryRegistry.cs | 5 - .../Controllers/DomainEventController.cs | 6 +- .../Controllers/EmailController.cs | 2 +- MessagingService/MessagingService.csproj | 40 ++++---- 26 files changed, 144 insertions(+), 363 deletions(-) delete mode 100644 MessagingService.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs delete mode 100644 MessagingService.Tests/ControllerTests.cs diff --git a/MessagingService.BusinessLogic.Tests/MessagingService.BusinessLogic.Tests.csproj b/MessagingService.BusinessLogic.Tests/MessagingService.BusinessLogic.Tests.csproj index 266fc2c..81aeaed 100644 --- a/MessagingService.BusinessLogic.Tests/MessagingService.BusinessLogic.Tests.csproj +++ b/MessagingService.BusinessLogic.Tests/MessagingService.BusinessLogic.Tests.csproj @@ -7,12 +7,12 @@ - + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MessagingService.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs b/MessagingService.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs deleted file mode 100644 index d2ac8f4..0000000 --- a/MessagingService.BusinessLogic/Common/ConfigurationReaderConnectionStringRepository.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace MessagingService.BusinessLogic.Common -{ - using System.Data.Common; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Data.SqlClient; - using MySqlConnector; - using Shared.General; - using Shared.Repositories; - - [ExcludeFromCodeCoverage] - public class ConfigurationReaderConnectionStringRepository : IConnectionStringConfigurationRepository - { - #region Methods - - /// - /// Creates the connection string. - /// - /// The external identifier. - /// Type of the connection string. - /// The connection string. - /// The cancellation token. - public async Task CreateConnectionString(String externalIdentifier, - String connectionStringIdentifier, - String connectionString, - CancellationToken cancellationToken) - { - throw new NotImplementedException("This is only required to complete the interface"); - } - - /// - /// Deletes the connection string configuration. - /// - /// The external identifier. - /// Type of the connection string. - /// The cancellation token. - public async Task DeleteConnectionStringConfiguration(String externalIdentifier, - String connectionStringIdentifier, - CancellationToken cancellationToken) - { - throw new NotImplementedException("This is only required to complete the interface"); - } - - /// - /// Gets the connection string. - /// - /// The external identifier. - /// Type of the connection string. - /// The cancellation token. - /// - public async Task GetConnectionString(String externalIdentifier, - String connectionStringIdentifier, - CancellationToken cancellationToken) - { - String connectionString = string.Empty; - String databaseName = string.Empty; - - String databaseEngine = ConfigurationReader.GetValue("AppSettings", "DatabaseEngine"); - - databaseName = $"{connectionStringIdentifier}{externalIdentifier}"; - connectionString = ConfigurationReader.GetConnectionString(connectionStringIdentifier); - - DbConnectionStringBuilder builder = null; - - if (databaseEngine == "MySql") - { - builder = new MySqlConnectionStringBuilder(connectionString) - { - Database = databaseName - }; - } - else - { - // Default to SQL Server - builder = new SqlConnectionStringBuilder(connectionString) - { - InitialCatalog = databaseName - }; - } - - return builder.ToString(); - } - - #endregion - } -} diff --git a/MessagingService.BusinessLogic/MessagingService.BusinessLogic.csproj b/MessagingService.BusinessLogic/MessagingService.BusinessLogic.csproj index 1d9ade8..c7b6d8e 100644 --- a/MessagingService.BusinessLogic/MessagingService.BusinessLogic.csproj +++ b/MessagingService.BusinessLogic/MessagingService.BusinessLogic.csproj @@ -5,12 +5,12 @@ - - - - - - + + + + + + @@ -20,4 +20,8 @@ + + + + diff --git a/MessagingService.Client/IMessagingServiceClient.cs b/MessagingService.Client/IMessagingServiceClient.cs index 2466da0..143dde6 100644 --- a/MessagingService.Client/IMessagingServiceClient.cs +++ b/MessagingService.Client/IMessagingServiceClient.cs @@ -13,14 +13,6 @@ namespace MessagingService.Client public interface IMessagingServiceClient { #region Methods - - /// - /// Sends the email. - /// - /// The access token. - /// The request. - /// The cancellation token. - /// Task SendEmail(String accessToken, SendEmailRequest request, CancellationToken cancellationToken); @@ -29,13 +21,6 @@ Task ResendEmail(String accessToken, ResendEmailRequest request, CancellationToken cancellationToken); - /// - /// Sends the SMS. - /// - /// The access token. - /// The request. - /// The cancellation token. - /// Task SendSMS(String accessToken, SendSMSRequest request, CancellationToken cancellationToken); diff --git a/MessagingService.Client/MessagingService.Client.csproj b/MessagingService.Client/MessagingService.Client.csproj index 98423c6..cfe8a5d 100644 --- a/MessagingService.Client/MessagingService.Client.csproj +++ b/MessagingService.Client/MessagingService.Client.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/MessagingService.Client/MessagingServiceClient.cs b/MessagingService.Client/MessagingServiceClient.cs index 0a0900e..8a0eab9 100644 --- a/MessagingService.Client/MessagingServiceClient.cs +++ b/MessagingService.Client/MessagingServiceClient.cs @@ -13,34 +13,18 @@ namespace MessagingService.Client using Newtonsoft.Json; using SimpleResults; - /// - /// - /// - /// - /// public class MessagingServiceClient : ClientProxyBase, IMessagingServiceClient { #region Fields - /// - /// The base address - /// private readonly String BaseAddress; - /// - /// The base address resolver - /// private readonly Func BaseAddressResolver; #endregion #region Constructors - /// - /// Initializes a new instance of the class. - /// - /// The base address resolver. - /// The HTTP client. public MessagingServiceClient(Func baseAddressResolver, HttpClient httpClient) : base(httpClient) { @@ -51,13 +35,6 @@ public MessagingServiceClient(Func baseAddressResolver, #region Methods - /// - /// Sends the email. - /// - /// The access token. - /// The send email request. - /// The cancellation token. - /// public async Task SendEmail(String accessToken, SendEmailRequest sendEmailRequest, CancellationToken cancellationToken) @@ -66,19 +43,8 @@ public async Task SendEmail(String accessToken, try { - String requestSerialised = JsonConvert.SerializeObject(sendEmailRequest); - - StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); - - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); - + Result result = await this.SendPostRequest(requestUri, accessToken, sendEmailRequest, cancellationToken); + if (result.IsFailed) return ResultHelpers.CreateFailure(result); @@ -99,18 +65,7 @@ public async Task ResendEmail(String accessToken, String requestUri = this.BuildRequestUrl("/api/email/resend"); try { - String requestSerialised = JsonConvert.SerializeObject(resendEmailRequest); - - StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); - - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + Result result = await this.SendPostRequest(requestUri, accessToken, resendEmailRequest, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); @@ -125,13 +80,6 @@ public async Task ResendEmail(String accessToken, } } - /// - /// Sends the SMS. - /// - /// The access token. - /// The send SMS request. - /// The cancellation token. - /// public async Task SendSMS(String accessToken, SendSMSRequest sendSMSRequest, CancellationToken cancellationToken) @@ -140,18 +88,7 @@ public async Task SendSMS(String accessToken, try { - String requestSerialised = JsonConvert.SerializeObject(sendSMSRequest); - - StringContent httpContent = new(requestSerialised, Encoding.UTF8, "application/json"); - - // Add the access token to the client headers - this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - - // Make the Http Call here - HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken); - - // Process the response - Result result = await this.HandleResponseX(httpResponse, cancellationToken); + Result result = await this.SendPostRequest(requestUri, accessToken, sendSMSRequest, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); @@ -166,12 +103,6 @@ public async Task SendSMS(String accessToken, throw exception; } } - - /// - /// Builds the request URL. - /// - /// The route. - /// private String BuildRequestUrl(String route) { String baseAddress = this.BaseAddressResolver("MessagingServiceApi"); diff --git a/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj b/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj index 3817ce1..823bb04 100644 --- a/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj +++ b/MessagingService.DataTransferObjects/MessagingService.DataTransferObjects.csproj @@ -9,7 +9,7 @@ - + diff --git a/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj b/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj index 1089736..9caf22c 100644 --- a/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj +++ b/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj @@ -7,11 +7,11 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj b/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj index 34fb458..c0e9f3e 100644 --- a/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj +++ b/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/MessagingService.EmailMessageAggregate/EmailAggregate.cs b/MessagingService.EmailMessageAggregate/EmailAggregate.cs index 9036ab1..a192c43 100644 --- a/MessagingService.EmailMessageAggregate/EmailAggregate.cs +++ b/MessagingService.EmailMessageAggregate/EmailAggregate.cs @@ -295,7 +295,8 @@ public EmailAggregate() private EmailAggregate(Guid aggregateId) { - Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); + if (aggregateId == Guid.Empty) + throw new ArgumentNullException(nameof(aggregateId)); this.AggregateId = aggregateId; this.MessageId = aggregateId; diff --git a/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj b/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj index 44a8e77..ee71973 100644 --- a/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj +++ b/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj b/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj index 5458c8c..80ef559 100644 --- a/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj +++ b/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj @@ -7,7 +7,7 @@ - + diff --git a/MessagingService.IntegrationTests/Common/Setup.cs b/MessagingService.IntegrationTests/Common/Setup.cs index 3986eea..d2bac8b 100644 --- a/MessagingService.IntegrationTests/Common/Setup.cs +++ b/MessagingService.IntegrationTests/Common/Setup.cs @@ -26,7 +26,7 @@ public static async Task GlobalSetup(DockerHelper dockerHelper) dockerHelper.SqlCredentials = Setup.SqlCredentials; dockerHelper.DockerCredentials = Setup.DockerCredentials; dockerHelper.SqlServerContainerName = "sharedsqlserver"; - + // Only one thread can execute this block at a time lock (Setup.padLock) { diff --git a/MessagingService.IntegrationTests/Email/SendEmail.feature.cs b/MessagingService.IntegrationTests/Email/SendEmail.feature.cs index 9f23491..732c33a 100644 --- a/MessagingService.IntegrationTests/Email/SendEmail.feature.cs +++ b/MessagingService.IntegrationTests/Email/SendEmail.feature.cs @@ -1,8 +1,8 @@ // ------------------------------------------------------------------------------ // -// This code was generated by Reqnroll (https://www.reqnroll.net/). -// Reqnroll Version:2.0.0.0 -// Reqnroll Generator Version:2.0.0.0 +// This code was generated by Reqnroll (https://reqnroll.net/). +// Reqnroll Version:3.0.0.0 +// Reqnroll Generator Version:3.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -15,14 +15,14 @@ namespace MessagingService.IntegrationTests.Email { - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [NUnit.Framework.TestFixtureAttribute()] - [NUnit.Framework.DescriptionAttribute("SendEmail")] - [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] - [NUnit.Framework.CategoryAttribute("base")] - [NUnit.Framework.CategoryAttribute("shared")] - [NUnit.Framework.CategoryAttribute("email")] + [global::NUnit.Framework.TestFixtureAttribute()] + [global::NUnit.Framework.DescriptionAttribute("SendEmail")] + [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] + [global::NUnit.Framework.CategoryAttribute("base")] + [global::NUnit.Framework.CategoryAttribute("shared")] + [global::NUnit.Framework.CategoryAttribute("email")] public partial class SendEmailFeature { @@ -33,22 +33,23 @@ public partial class SendEmailFeature "shared", "email"}; - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Email", "SendEmail", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); + private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "Email", "SendEmail", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); #line 1 "SendEmail.feature" #line hidden - [NUnit.Framework.OneTimeSetUpAttribute()] + [global::NUnit.Framework.OneTimeSetUpAttribute()] public static async global::System.Threading.Tasks.Task FeatureSetupAsync() { } - [NUnit.Framework.OneTimeTearDownAttribute()] + [global::NUnit.Framework.OneTimeTearDownAttribute()] public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() { + await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); } - [NUnit.Framework.SetUpAttribute()] + [global::NUnit.Framework.SetUpAttribute()] public async global::System.Threading.Tasks.Task TestInitializeAsync() { testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); @@ -74,7 +75,7 @@ public partial class SendEmailFeature } } - [NUnit.Framework.TearDownAttribute()] + [global::NUnit.Framework.TearDownAttribute()] public async global::System.Threading.Tasks.Task TestTearDownAsync() { if ((testRunner == null)) @@ -92,10 +93,10 @@ public partial class SendEmailFeature } } - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); } public async global::System.Threading.Tasks.Task ScenarioStartAsync() @@ -162,21 +163,29 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) #line hidden } - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Send Email")] - [NUnit.Framework.CategoryAttribute("PRTest")] + private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() + { + return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("Email/SendEmail.feature.ndjson", 3); + } + + [global::NUnit.Framework.TestAttribute()] + [global::NUnit.Framework.DescriptionAttribute("Send Email")] + [global::NUnit.Framework.CategoryAttribute("PRTest")] public async global::System.Threading.Tasks.Task SendEmail() { string[] tagsOfScenario = new string[] { "PRTest"}; global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Send Email", null, tagsOfScenario, argumentsOfScenario, featureTags); + string pickleIndex = "0"; + global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Send Email", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); + string[] tagsOfRule = ((string[])(null)); + global::Reqnroll.RuleInfo ruleInfo = null; #line 23 -this.ScenarioInitialize(scenarioInfo); +this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) { - testRunner.SkipScenario(); + await testRunner.SkipScenarioAsync(); } else { diff --git a/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj b/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj index 548f8eb..656a4a4 100644 --- a/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj +++ b/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj @@ -6,17 +6,17 @@ - - - - - - - - - - - + + + + + + + + + + + all diff --git a/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs b/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs index 20f8cb0..9c4119e 100644 --- a/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs +++ b/MessagingService.IntegrationTests/SMS/SendSMS.feature.cs @@ -1,8 +1,8 @@ // ------------------------------------------------------------------------------ // -// This code was generated by Reqnroll (https://www.reqnroll.net/). -// Reqnroll Version:2.0.0.0 -// Reqnroll Generator Version:2.0.0.0 +// This code was generated by Reqnroll (https://reqnroll.net/). +// Reqnroll Version:3.0.0.0 +// Reqnroll Generator Version:3.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -15,14 +15,14 @@ namespace MessagingService.IntegrationTests.SMS { - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "2.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Reqnroll", "3.0.0.0")] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [NUnit.Framework.TestFixtureAttribute()] - [NUnit.Framework.DescriptionAttribute("SendSMS")] - [NUnit.Framework.FixtureLifeCycleAttribute(NUnit.Framework.LifeCycle.InstancePerTestCase)] - [NUnit.Framework.CategoryAttribute("base")] - [NUnit.Framework.CategoryAttribute("shared")] - [NUnit.Framework.CategoryAttribute("sms")] + [global::NUnit.Framework.TestFixtureAttribute()] + [global::NUnit.Framework.DescriptionAttribute("SendSMS")] + [global::NUnit.Framework.FixtureLifeCycleAttribute(global::NUnit.Framework.LifeCycle.InstancePerTestCase)] + [global::NUnit.Framework.CategoryAttribute("base")] + [global::NUnit.Framework.CategoryAttribute("shared")] + [global::NUnit.Framework.CategoryAttribute("sms")] public partial class SendSMSFeature { @@ -33,22 +33,23 @@ public partial class SendSMSFeature "shared", "sms"}; - private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "SMS", "SendSMS", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags); + private static global::Reqnroll.FeatureInfo featureInfo = new global::Reqnroll.FeatureInfo(new global::System.Globalization.CultureInfo("en-US"), "SMS", "SendSMS", null, global::Reqnroll.ProgrammingLanguage.CSharp, featureTags, InitializeCucumberMessages()); #line 1 "SendSMS.feature" #line hidden - [NUnit.Framework.OneTimeSetUpAttribute()] + [global::NUnit.Framework.OneTimeSetUpAttribute()] public static async global::System.Threading.Tasks.Task FeatureSetupAsync() { } - [NUnit.Framework.OneTimeTearDownAttribute()] + [global::NUnit.Framework.OneTimeTearDownAttribute()] public static async global::System.Threading.Tasks.Task FeatureTearDownAsync() { + await global::Reqnroll.TestRunnerManager.ReleaseFeatureAsync(featureInfo); } - [NUnit.Framework.SetUpAttribute()] + [global::NUnit.Framework.SetUpAttribute()] public async global::System.Threading.Tasks.Task TestInitializeAsync() { testRunner = global::Reqnroll.TestRunnerManager.GetTestRunnerForAssembly(featureHint: featureInfo); @@ -74,7 +75,7 @@ public partial class SendSMSFeature } } - [NUnit.Framework.TearDownAttribute()] + [global::NUnit.Framework.TearDownAttribute()] public async global::System.Threading.Tasks.Task TestTearDownAsync() { if ((testRunner == null)) @@ -92,10 +93,10 @@ public partial class SendSMSFeature } } - public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) + public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo, global::Reqnroll.RuleInfo ruleInfo) { - testRunner.OnScenarioInitialize(scenarioInfo); - testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + testRunner.OnScenarioInitialize(scenarioInfo, ruleInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(global::NUnit.Framework.TestContext.CurrentContext); } public async global::System.Threading.Tasks.Task ScenarioStartAsync() @@ -162,21 +163,29 @@ public void ScenarioInitialize(global::Reqnroll.ScenarioInfo scenarioInfo) #line hidden } - [NUnit.Framework.TestAttribute()] - [NUnit.Framework.DescriptionAttribute("Send SMS")] - [NUnit.Framework.CategoryAttribute("PRTest")] + private static global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages InitializeCucumberMessages() + { + return new global::Reqnroll.Formatters.RuntimeSupport.FeatureLevelCucumberMessages("SMS/SendSMS.feature.ndjson", 3); + } + + [global::NUnit.Framework.TestAttribute()] + [global::NUnit.Framework.DescriptionAttribute("Send SMS")] + [global::NUnit.Framework.CategoryAttribute("PRTest")] public async global::System.Threading.Tasks.Task SendSMS() { string[] tagsOfScenario = new string[] { "PRTest"}; global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Send SMS", null, tagsOfScenario, argumentsOfScenario, featureTags); + string pickleIndex = "0"; + global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Send SMS", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); + string[] tagsOfRule = ((string[])(null)); + global::Reqnroll.RuleInfo ruleInfo = null; #line 23 -this.ScenarioInitialize(scenarioInfo); +this.ScenarioInitialize(scenarioInfo, ruleInfo); #line hidden if ((global::Reqnroll.TagHelper.ContainsIgnoreTag(scenarioInfo.CombinedTags) || global::Reqnroll.TagHelper.ContainsIgnoreTag(featureTags))) { - testRunner.SkipScenario(); + await testRunner.SkipScenarioAsync(); } else { diff --git a/MessagingService.SMSAggregate.Tests/MessagingService.SMSAggregate.Tests.csproj b/MessagingService.SMSAggregate.Tests/MessagingService.SMSAggregate.Tests.csproj index 05ba2b0..d357bb1 100644 --- a/MessagingService.SMSAggregate.Tests/MessagingService.SMSAggregate.Tests.csproj +++ b/MessagingService.SMSAggregate.Tests/MessagingService.SMSAggregate.Tests.csproj @@ -7,10 +7,10 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj b/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj index bd7b3ec..e328df7 100644 --- a/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj +++ b/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj @@ -6,7 +6,7 @@ - + diff --git a/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj b/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj index 194227b..20f688c 100644 --- a/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj +++ b/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj @@ -6,7 +6,7 @@ - + diff --git a/MessagingService.SMSMessageAggregate/SMSAggregate.cs b/MessagingService.SMSMessageAggregate/SMSAggregate.cs index 863e200..6d69ab3 100644 --- a/MessagingService.SMSMessageAggregate/SMSAggregate.cs +++ b/MessagingService.SMSMessageAggregate/SMSAggregate.cs @@ -177,7 +177,8 @@ public SMSAggregate(){ } private SMSAggregate(Guid aggregateId){ - Guard.ThrowIfInvalidGuid(aggregateId, "Aggregate Id cannot be an Empty Guid"); + if (aggregateId == Guid.Empty) + throw new ArgumentNullException(nameof(aggregateId)); this.AggregateId = aggregateId; this.MessageId = aggregateId; diff --git a/MessagingService.Tests/ControllerTests.cs b/MessagingService.Tests/ControllerTests.cs deleted file mode 100644 index 97cd806..0000000 --- a/MessagingService.Tests/ControllerTests.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MessagingService.Tests -{ - using System.Threading; - using Controllers; - using MessagingService.EmailMessage.DomainEvents; - using Microsoft.AspNetCore.Http; - using Microsoft.AspNetCore.Mvc; - using Moq; - using Newtonsoft.Json; - using Shared.EventStore.EventHandling; - using Shared.General; - using Shared.Logger; - using Shouldly; - using Xunit; - - public class ControllerTests - { - public ControllerTests() { - Logger.Initialise(new NullLogger()); - } - [Fact] - public async Task DomainEventController_EventIdNotPresentInJson_ErrorThrown() { - Mock resolver = new(); - TypeMap.AddType("ResponseReceivedFromEmailProviderEvent"); - DefaultHttpContext httpContext = new(); - httpContext.Request.Headers["eventType"] = "ResponseReceivedFromEmailProviderEvent"; - DomainEventController controller = new(resolver.Object) - { - ControllerContext = new ControllerContext() - { - HttpContext = httpContext - } - }; - String json = "{\r\n \"messageId\": \"811bb215-0d99-4639-ac3a-195ba4a47449\",\r\n \"providerRequestReference\": \"d8f669fa-675d-11ec-8b59-f23c92160e3c\"\r\n}\t"; - Object request = JsonConvert.DeserializeObject(json); - ArgumentException ex = Should.Throw(() => controller.PostEventAsync(request, CancellationToken.None)); - ex.Message.ShouldBe("Domain Event must contain an Event Id"); - } - - [Fact] - public async Task DomainEventController_EventIdPresentInJson_NoErrorThrown() - { - Mock resolver = new(); - TypeMap.AddType("ResponseReceivedFromEmailProviderEvent"); - DefaultHttpContext httpContext = new(); - httpContext.Request.Headers["eventType"] = "ResponseReceivedFromEmailProviderEvent"; - DomainEventController controller = new(resolver.Object) - { - ControllerContext = new ControllerContext() - { - HttpContext = httpContext - } - }; - String json = "{\r\n \"messageId\": \"811bb215-0d99-4639-ac3a-195ba4a47449\",\r\n \"providerRequestReference\": \"d8f669fa-675d-11ec-8b59-f23c92160e3c\",\r\n \"eventId\": \"123bb215-0d99-4639-ac3a-195ba4a47449\"\r\n}\t"; - Object request = JsonConvert.DeserializeObject(json); - Should.NotThrow(async () => await controller.PostEventAsync(request, CancellationToken.None)); - } - } -} diff --git a/MessagingService.Tests/MessagingService.Tests.csproj b/MessagingService.Tests/MessagingService.Tests.csproj index 3607cf2..8d1c9a0 100644 --- a/MessagingService.Tests/MessagingService.Tests.csproj +++ b/MessagingService.Tests/MessagingService.Tests.csproj @@ -7,13 +7,13 @@ - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MessagingService/Bootstrapper/RepositoryRegistry.cs b/MessagingService/Bootstrapper/RepositoryRegistry.cs index 042bc7b..17600ba 100644 --- a/MessagingService/Bootstrapper/RepositoryRegistry.cs +++ b/MessagingService/Bootstrapper/RepositoryRegistry.cs @@ -4,19 +4,16 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Http; using System.Net.Security; -using BusinessLogic.Common; using Common; using EmailMessageAggregate; using Lamar; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Shared.DomainDrivenDesign.EventSourcing; -using Shared.EntityFramework.ConnectionStringConfiguration; using Shared.EventStore.Aggregate; using Shared.EventStore.EventStore; using Shared.EventStore.SubscriptionWorker; using Shared.General; -using Shared.Repositories; using SMSMessageAggregate; [ExcludeFromCodeCoverage] @@ -31,8 +28,6 @@ public RepositoryRegistry() this.AddEventStoreClient(connectionString); - this.AddSingleton(); - this.AddTransient(); this.AddSingleton, AggregateRepository>(); diff --git a/MessagingService/Controllers/DomainEventController.cs b/MessagingService/Controllers/DomainEventController.cs index 4efff4e..95deb4d 100644 --- a/MessagingService/Controllers/DomainEventController.cs +++ b/MessagingService/Controllers/DomainEventController.cs @@ -67,14 +67,16 @@ public async Task PostEventAsync([FromBody] Object request, try { Logger.LogInformation($"Processing event - ID [{domainEvent.EventId}], Type[{domainEvent.GetType().Name}]"); - List eventHandlers = this.DomainEventHandlerResolver.GetDomainEventHandlers(domainEvent); + var eventHandlersResult = this.DomainEventHandlerResolver.GetDomainEventHandlers(domainEvent); - if (eventHandlers == null || eventHandlers.Any() == false) { + if (eventHandlersResult.IsFailed) { // Log a warning out Logger.LogWarning($"No event handlers configured for Event Type [{domainEvent.GetType().Name}]"); return this.Ok(); } + var eventHandlers = eventHandlersResult.Data; + List tasks = new List(); foreach (IDomainEventHandler domainEventHandler in eventHandlers) { tasks.Add(domainEventHandler.Handle(domainEvent, cancellationToken)); diff --git a/MessagingService/Controllers/EmailController.cs b/MessagingService/Controllers/EmailController.cs index e129a42..7ce902e 100644 --- a/MessagingService/Controllers/EmailController.cs +++ b/MessagingService/Controllers/EmailController.cs @@ -29,7 +29,7 @@ namespace MessagingService.Controllers [ExcludeFromCodeCoverage] [Route(EmailController.ControllerRoute)] [ApiController] - //[Authorize] + [Authorize] public class EmailController : ControllerBase { #region Fields diff --git a/MessagingService/MessagingService.csproj b/MessagingService/MessagingService.csproj index 5ed87ba..9dc3db1 100644 --- a/MessagingService/MessagingService.csproj +++ b/MessagingService/MessagingService.csproj @@ -10,29 +10,29 @@ - - + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - + + + + + + + From 209a68d9018bd57cff0cb0293ffa101ea080ecfd Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Fri, 24 Oct 2025 21:20:41 +0100 Subject: [PATCH 2/2] fix broken tests --- MessagingService.Client/MessagingServiceClient.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MessagingService.Client/MessagingServiceClient.cs b/MessagingService.Client/MessagingServiceClient.cs index 8a0eab9..9d63bda 100644 --- a/MessagingService.Client/MessagingServiceClient.cs +++ b/MessagingService.Client/MessagingServiceClient.cs @@ -43,7 +43,7 @@ public async Task SendEmail(String accessToken, try { - Result result = await this.SendPostRequest(requestUri, accessToken, sendEmailRequest, cancellationToken); + Result> result = await this.SendPostRequest>(requestUri, accessToken, sendEmailRequest, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); @@ -65,7 +65,7 @@ public async Task ResendEmail(String accessToken, String requestUri = this.BuildRequestUrl("/api/email/resend"); try { - Result result = await this.SendPostRequest(requestUri, accessToken, resendEmailRequest, cancellationToken); + Result> result = await this.SendPostRequest>(requestUri, accessToken, resendEmailRequest, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result); @@ -88,7 +88,7 @@ public async Task SendSMS(String accessToken, try { - Result result = await this.SendPostRequest(requestUri, accessToken, sendSMSRequest, cancellationToken); + Result> result = await this.SendPostRequest>(requestUri, accessToken, sendSMSRequest, cancellationToken); if (result.IsFailed) return ResultHelpers.CreateFailure(result);