From 0d478b48b0692b688e64c7e41b5108db6f18d284 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 08:29:16 +0000 Subject: [PATCH 1/2] refactor: use file scoped namespaces This PR refactors test classes to leverage C# 10 file-scoped namespaces. It relocates using directives to the top of each file and removes unnecessary region directives for improved readability and consistency across the codebase. - Use File Scoped `namespace`s instead of typical `namespace`s: Legacy block-scoped namespace declarations in Shared.EventStore.Tests and Shared.Tests were converted to file-scoped namespaces at the top of each file. All using directives were consolidated above the namespace, and extraneous #region blocks were removed to streamline the code structure and adhere to modern C# conventions. > This Autofix was generated by AI. Please review the change before merging. --- .../DomainEventHelperTests.cs | 83 ++++++++++--------- .../SubscriptionRepositoryTests.cs | 45 +++++----- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Shared.EventStore.Tests/DomainEventHelperTests.cs b/Shared.EventStore.Tests/DomainEventHelperTests.cs index 981ef7c..b19c739 100644 --- a/Shared.EventStore.Tests/DomainEventHelperTests.cs +++ b/Shared.EventStore.Tests/DomainEventHelperTests.cs @@ -4,56 +4,57 @@ using System.Text; using System.Threading.Tasks; -namespace Shared.Tests -{ - using DomainDrivenDesign.EventSourcing; - using EventStore.Tests; - using Shared.EventStore.Tests.TestObjects; - using Shouldly; - using Xunit; +namespace Shared.Tests; + +using DomainDrivenDesign.EventSourcing; +using EventStore.Tests; +using Shared.EventStore.Tests.TestObjects; +using Shouldly; +using Xunit; - public class DomainEventHelperTests +public class DomainEventHelperTests +{ + [Fact] + public void DomainEventHelper_GetProperty_CorrectCase_PropertyNotFound() { - [Fact] - public void DomainEventHelper_GetProperty_CorrectCase_PropertyNotFound() - { - AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); - String propertyValue = DomainEventHelper.GetProperty(domainEvent, "AggregateName1"); - propertyValue.ShouldBe(default); - } + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); + String propertyValue = DomainEventHelper.GetProperty(domainEvent, "AggregateName1"); + propertyValue.ShouldBe(default); + } - [Theory] - [InlineData("AggregateName1")] - [InlineData("aggregatename1")] - [InlineData("AGGREGATENAME1")] - public void DomainEventHelper_GetProperty_IgnoreCase_PropertyNotFound(String propertyName) - { + [Theory] + [InlineData("AggregateName1")] + [InlineData("aggregatename1")] + [InlineData("AGGREGATENAME1")] + public void DomainEventHelper_GetProperty_IgnoreCase_PropertyNotFound(String propertyName) + { - AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); - String propertyValue = DomainEventHelper.GetProperty(domainEvent, propertyName, true); - propertyValue.ShouldBe(default); - } + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); + String propertyValue = DomainEventHelper.GetProperty(domainEvent, propertyName, true); + propertyValue.ShouldBe(default); + } - [Fact] - public void DomainEventHelper_GetProperty_CorrectCase_PropertyFound(){ + [Fact] + public void DomainEventHelper_GetProperty_CorrectCase_PropertyFound(){ - AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); - String propertyValue = DomainEventHelper.GetProperty(domainEvent, "AggregateName"); - propertyValue.ShouldBe(TestData.EstateName); - } + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); + String propertyValue = DomainEventHelper.GetProperty(domainEvent, "AggregateName"); + propertyValue.ShouldBe(TestData.EstateName); + } - [Theory] - [InlineData("AggregateName")] - [InlineData("aggregatename")] - [InlineData("AGGREGATENAME")] - public void DomainEventHelper_GetProperty_IgnoreCase_PropertyFound(String propertyName) - { + [Theory] + [InlineData("AggregateName")] + [InlineData("aggregatename")] + [InlineData("AGGREGATENAME")] + public void DomainEventHelper_GetProperty_IgnoreCase_PropertyFound(String propertyName) + { - AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); - String propertyValue = DomainEventHelper.GetProperty(domainEvent, propertyName, true); - propertyValue.ShouldBe(TestData.EstateName); - } + AggregateNameSetEvent domainEvent = new(TestData.AggregateId, TestData.EventId, TestData.EstateName); + String propertyValue = DomainEventHelper.GetProperty(domainEvent, propertyName, true); + propertyValue.ShouldBe(TestData.EstateName); + } +} [Theory] [InlineData("AggregateName", true)] diff --git a/Shared.EventStore.Tests/SubscriptionRepositoryTests.cs b/Shared.EventStore.Tests/SubscriptionRepositoryTests.cs index caf1bb2..367d5f9 100644 --- a/Shared.EventStore.Tests/SubscriptionRepositoryTests.cs +++ b/Shared.EventStore.Tests/SubscriptionRepositoryTests.cs @@ -1,33 +1,32 @@ using Shared.EventStore.Tests.TestObjects; -namespace Shared.EventStore.Tests -{ - using System; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - using Shouldly; - using SubscriptionWorker; - using Xunit; - - public class SubscriptionRepositoryTests - { - #region Methods +namespace Shared.EventStore.Tests; + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Shouldly; +using SubscriptionWorker; +using Xunit; - [Fact] - public async Task SubscriptionRepository_GetSubscriptions_ReturnsSubscriptions() - { - List allSubscriptions = (TestData.GetPersistentSubscriptions_DemoEstate()); +public class SubscriptionRepositoryTests +{ + #region Methods - Func>> GetAllSubscriptions = async token => allSubscriptions; + [Fact] + public async Task SubscriptionRepository_GetSubscriptions_ReturnsSubscriptions() + { + List allSubscriptions = (TestData.GetPersistentSubscriptions_DemoEstate()); - ISubscriptionRepository subscriptionRepository = SubscriptionRepository.Create(GetAllSubscriptions); + Func>> GetAllSubscriptions = async token => allSubscriptions; - PersistentSubscriptions list = await subscriptionRepository.GetSubscriptions(true, CancellationToken.None); + ISubscriptionRepository subscriptionRepository = SubscriptionRepository.Create(GetAllSubscriptions); - list.PersistentSubscriptionInfo.Count.ShouldBe(allSubscriptions.Count); - } + PersistentSubscriptions list = await subscriptionRepository.GetSubscriptions(true, CancellationToken.None); - #endregion + list.PersistentSubscriptionInfo.Count.ShouldBe(allSubscriptions.Count); } + + #endregion } \ No newline at end of file From 2cf7371fdbf39874faf77f26dd94cef37f9123f4 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Sat, 20 Sep 2025 09:31:59 +0100 Subject: [PATCH 2/2] .. --- Shared.EventStore.Tests/DomainEventHelperTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Shared.EventStore.Tests/DomainEventHelperTests.cs b/Shared.EventStore.Tests/DomainEventHelperTests.cs index b19c739..36b1dd0 100644 --- a/Shared.EventStore.Tests/DomainEventHelperTests.cs +++ b/Shared.EventStore.Tests/DomainEventHelperTests.cs @@ -54,7 +54,6 @@ public void DomainEventHelper_GetProperty_IgnoreCase_PropertyFound(String proper String propertyValue = DomainEventHelper.GetProperty(domainEvent, propertyName, true); propertyValue.ShouldBe(TestData.EstateName); } -} [Theory] [InlineData("AggregateName", true)] @@ -70,4 +69,3 @@ public void DomainEventHelper_HasProperty_ExpectedResultReturned(String property } } -}