diff --git a/Reshaper.DotSettings b/Reshaper.DotSettings index f16842f1..aa587c5c 100644 --- a/Reshaper.DotSettings +++ b/Reshaper.DotSettings @@ -1,6 +1,7 @@  True + False UseVisualStudio @@ -15,14 +16,14 @@ DO_NOT_SHOW DO_NOT_SHOW - True + Built-in: Full Cleanup True Built-in: Full Cleanup False True False - Join + ExpressionBody ExpressionBody public private internal static file new abstract protected virtual readonly override async extern unsafe volatile sealed required @@ -44,6 +45,7 @@ False False + 3 EXPANDED True @@ -77,251 +79,252 @@ 300 False True - <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> - <TypePattern DisplayName="Non-reorderable types"> - <TypePattern.Match> - <Or> - <And> - <Kind Is="Interface" /> - <Or> - <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" /> - <HasAttribute Name="System.Runtime.InteropServices.ComImport" /> - </Or> - </And> - <Kind Is="Struct" /> - <HasAttribute Name="JetBrains.Annotations.NoReorderAttribute" /> - <HasAttribute Name="JetBrains.Annotations.NoReorder" /> - </Or> - </TypePattern.Match> - </TypePattern> - - <TypePattern DisplayName="xUnit.net Test Classes" RemoveRegions="All"> - <TypePattern.Match> - <And> - <Kind Is="Class" /> - <HasMember> - <And> - <Kind Is="Method" /> - <HasAttribute Name="Xunit.FactAttribute" Inherited="True" /> - <HasAttribute Name="Xunit.TheoryAttribute" Inherited="True" /> - </And> - </HasMember> - </And> - </TypePattern.Match> - - <Entry DisplayName="Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Not> - <Static /> - </Not> - </And> - </Entry.Match> - - <Entry.SortBy> - <Readonly /> - <Name /> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="Constructors"> - <Entry.Match> - <Kind Is="Constructor" /> - </Entry.Match> - - <Entry.SortBy> - <Static/> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="Teardown Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <ImplementsInterface Name="System.IDisposable" /> - </And> - </Entry.Match> - </Entry> - - <Entry DisplayName="All other members" /> - - <Entry DisplayName="Test Methods" Priority="100"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <HasAttribute Name="Xunit.FactAttribute" Inherited="false" /> - <HasAttribute Name="Xunit.TheoryAttribute" Inherited="false" /> - </And> - </Entry.Match> - - <Entry.SortBy> - <Name /> - </Entry.SortBy> - </Entry> - </TypePattern> - - <TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All"> - <TypePattern.Match> - <And> - <Kind Is="Class" /> - <Or> - <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="true" /> - <HasAttribute Name="NUnit.Framework.TestFixtureSourceAttribute" Inherited="true" /> - <HasMember> - <And> - <Kind Is="Method" /> - <HasAttribute Name="NUnit.Framework.TestAttribute" Inherited="false" /> - <HasAttribute Name="NUnit.Framework.TestCaseAttribute" Inherited="false" /> - <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" Inherited="false" /> - </And> - </HasMember> - </Or> - </And> - </TypePattern.Match> - - <Entry DisplayName="Setup/Teardown Methods"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <Or> - <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="true" /> - <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="true" /> - <HasAttribute Name="NUnit.Framework.TestFixtureSetUpAttribute" Inherited="true" /> - <HasAttribute Name="NUnit.Framework.TestFixtureTearDownAttribute" Inherited="true" /> - <HasAttribute Name="NUnit.Framework.OneTimeSetUpAttribute" Inherited="true" /> - <HasAttribute Name="NUnit.Framework.OneTimeTearDownAttribute" Inherited="true" /> - </Or> - </And> - </Entry.Match> - </Entry> - - <Entry DisplayName="All other members" /> - - <Entry DisplayName="Test Methods" Priority="100"> - <Entry.Match> - <And> - <Kind Is="Method" /> - <HasAttribute Name="NUnit.Framework.TestAttribute" Inherited="false" /> - <HasAttribute Name="NUnit.Framework.TestCaseAttribute" Inherited="false" /> - <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" Inherited="false" /> - </And> - </Entry.Match> - - <Entry.SortBy> - <Name /> - </Entry.SortBy> - </Entry> - </TypePattern> - - <TypePattern DisplayName="Default Pattern"> - <Entry DisplayName="Public Delegates" Priority="100"> - <Entry.Match> - <And> - <Access Is="Public" /> - <Kind Is="Delegate" /> - </And> - </Entry.Match> - - <Entry.SortBy> - <Name /> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="Public Enums" Priority="100"> - <Entry.Match> - <And> - <Access Is="Public" /> - <Kind Is="Enum" /> - </And> - </Entry.Match> - - <Entry.SortBy> - <Name /> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="Static Fields and Constants"> - <Entry.Match> - <Or> - <Kind Is="Constant" /> - <And> - <Kind Is="Field" /> - <Static /> - </And> - </Or> - </Entry.Match> - - <Entry.SortBy> - <Kind> - <Kind.Order> - <DeclarationKind>Constant</DeclarationKind> - <DeclarationKind>Field</DeclarationKind> - </Kind.Order> - </Kind> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="Fields"> - <Entry.Match> - <And> - <Kind Is="Field" /> - <Not> - <Static /> - </Not> - </And> - </Entry.Match> - - <Entry.SortBy> - <Readonly /> - <Name /> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="Constructors"> - <Entry.Match> - <Kind Is="Constructor" /> - </Entry.Match> - - <Entry.SortBy> - <Static/> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="Properties, Indexers"> - <Entry.Match> - <Or> - <Kind Is="Property" /> - <Kind Is="Indexer" /> - </Or> - </Entry.Match> - </Entry> - - <Entry DisplayName="Interface Implementations" Priority="100"> - <Entry.Match> - <And> - <Kind Is="Member" /> - <ImplementsInterface /> - </And> - </Entry.Match> - - <Entry.SortBy> - <ImplementsInterface Immediate="true" /> - </Entry.SortBy> - </Entry> - - <Entry DisplayName="All other members" /> - - <Entry DisplayName="Nested Types"> - <Entry.Match> - <Kind Is="Type" /> - </Entry.Match> - </Entry> - </TypePattern> -</Patterns> + <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> + <TypePattern DisplayName="Non-reorderable types" Priority="99999999"> + <TypePattern.Match> + <Or> + <And> + <Kind Is="Interface" /> + <Or> + <HasAttribute Name="System.Runtime.InteropServices.InterfaceTypeAttribute" /> + <HasAttribute Name="System.Runtime.InteropServices.ComImport" /> + </Or> + </And> + <Kind Is="Struct" /> + <HasAttribute Name="System.Runtime.InteropServices.StructLayoutAttribute" /> + <HasAttribute Name="JetBrains.Annotations.NoReorderAttribute" /> + </Or> + </TypePattern.Match> + </TypePattern> + + <TypePattern DisplayName="xUnit.net Test Classes" RemoveRegions="All"> + <TypePattern.Match> + <And> + <Kind Is="Class" /> + <HasMember> + <And> + <Kind Is="Method" /> + <HasAttribute Name="Xunit.FactAttribute" Inherited="True" /> + <HasAttribute Name="Xunit.TheoryAttribute" Inherited="True" /> + </And> + </HasMember> + </And> + </TypePattern.Match> + + <Entry DisplayName="Fields"> + <Entry.Match> + <And> + <Kind Is="Field" /> + <Not> + <Static /> + </Not> + </And> + </Entry.Match> + + <Entry.SortBy> + <Readonly /> + <Name /> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="Constructors"> + <Entry.Match> + <Kind Is="Constructor" /> + </Entry.Match> + + <Entry.SortBy> + <Static/> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="Teardown Methods"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <ImplementsInterface Name="System.IDisposable" /> + </And> + </Entry.Match> + </Entry> + + <Entry DisplayName="All other members" /> + + <Entry DisplayName="Test Methods" Priority="100"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <HasAttribute Name="Xunit.FactAttribute" Inherited="false" /> + <HasAttribute Name="Xunit.TheoryAttribute" Inherited="false" /> + </And> + </Entry.Match> + + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> + + <TypePattern DisplayName="NUnit Test Fixtures" RemoveRegions="All"> + <TypePattern.Match> + <And> + <Kind Is="Class" /> + <Or> + <HasAttribute Name="NUnit.Framework.TestFixtureAttribute" Inherited="true" /> + <HasAttribute Name="NUnit.Framework.TestFixtureSourceAttribute" Inherited="true" /> + <HasMember> + <And> + <Kind Is="Method" /> + <HasAttribute Name="NUnit.Framework.TestAttribute" Inherited="false" /> + <HasAttribute Name="NUnit.Framework.TestCaseAttribute" Inherited="false" /> + <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" Inherited="false" /> + </And> + </HasMember> + </Or> + </And> + </TypePattern.Match> + + <Entry DisplayName="Setup/Teardown Methods"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <Or> + <HasAttribute Name="NUnit.Framework.SetUpAttribute" Inherited="true" /> + <HasAttribute Name="NUnit.Framework.TearDownAttribute" Inherited="true" /> + <HasAttribute Name="NUnit.Framework.TestFixtureSetUpAttribute" Inherited="true" /> + <HasAttribute Name="NUnit.Framework.TestFixtureTearDownAttribute" Inherited="true" /> + <HasAttribute Name="NUnit.Framework.OneTimeSetUpAttribute" Inherited="true" /> + <HasAttribute Name="NUnit.Framework.OneTimeTearDownAttribute" Inherited="true" /> + </Or> + </And> + </Entry.Match> + </Entry> + + <Entry DisplayName="All other members" /> + + <Entry DisplayName="Test Methods" Priority="100"> + <Entry.Match> + <And> + <Kind Is="Method" /> + <HasAttribute Name="NUnit.Framework.TestAttribute" Inherited="false" /> + <HasAttribute Name="NUnit.Framework.TestCaseAttribute" Inherited="false" /> + <HasAttribute Name="NUnit.Framework.TestCaseSourceAttribute" Inherited="false" /> + </And> + </Entry.Match> + + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + </TypePattern> + + <TypePattern DisplayName="Default Pattern"> + <Entry DisplayName="Public Delegates" Priority="100"> + <Entry.Match> + <And> + <Access Is="Public" /> + <Kind Is="Delegate" /> + </And> + </Entry.Match> + + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="Public Enums" Priority="100"> + <Entry.Match> + <And> + <Access Is="Public" /> + <Kind Is="Enum" /> + </And> + </Entry.Match> + + <Entry.SortBy> + <Name /> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="Static Fields and Constants"> + <Entry.Match> + <Or> + <Kind Is="Constant" /> + <And> + <Kind Is="Field" /> + <Static /> + </And> + </Or> + </Entry.Match> + + <Entry.SortBy> + <Kind> + <Kind.Order> + <DeclarationKind>Constant</DeclarationKind> + <DeclarationKind>Field</DeclarationKind> + </Kind.Order> + </Kind> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="Fields"> + <Entry.Match> + <And> + <Kind Is="Field" /> + <Not> + <Static /> + </Not> + </And> + </Entry.Match> + + <Entry.SortBy> + <Readonly /> + <Name /> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="Constructors"> + <Entry.Match> + <Kind Is="Constructor" /> + </Entry.Match> + + <Entry.SortBy> + <Static/> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="Properties, Indexers"> + <Entry.Match> + <Or> + <Kind Is="Property" /> + <Kind Is="Indexer" /> + </Or> + </Entry.Match> + </Entry> + + <Entry DisplayName="Interface Implementations" Priority="100"> + <Entry.Match> + <And> + <Kind Is="Member" /> + <ImplementsInterface /> + </And> + </Entry.Match> + + <Entry.SortBy> + <ImplementsInterface Immediate="true" /> + </Entry.SortBy> + </Entry> + + <Entry DisplayName="All other members" /> + + <Entry DisplayName="Nested Types"> + <Entry.Match> + <Kind Is="Type" /> + </Entry.Match> + </Entry> + </TypePattern> +</Patterns> True + True True Skip @@ -348,18 +351,39 @@ False - 81499 + 95279 PackageReference True + DO_NOTHING + DO_NOTHING + DO_NOTHING + DO_NOTHING - LIVE_MONITOR + DO_NOTHING + DO_NOTHING DO_NOTHING + DO_NOTHING + DO_NOTHING + DO_NOTHING + DO_NOTHING + DO_NOTHING + DO_NOTHING + DO_NOTHING + + True + + True + + True + + True + @@ -375,12 +399,28 @@ - NOTIFY + + True True + + True + + True + + True + + True + + True + + True + + True + 12 @@ -399,6 +439,7 @@ 9 2 0 + 2 2 True True @@ -408,8 +449,11 @@ True True True - 10/02/2024 14:40:39 - 10/02/2024 06:56:15 + 10/16/2024 09:22:06 + 10/09/2024 06:11:58 + 10/09/2024 06:11:59 + 10/16/2024 02:45:39 + 0 @@ -422,15 +466,17 @@ True True Enabled - 10/02/2024 14:51:22 + 10/16/2024 10:41:21 True True True True True True + True True + True True True @@ -439,7 +485,7 @@ True True - [21,-99](1298,768) + [41,-18](1298,768) -211,-121 422 268.5 @@ -452,10 +498,11 @@ True - VsIntegrationOptionsPage + CodeCleanupOptionsPage True + True - 1 + 1.000925925925926 True True 02/23/2024 04:49:50 @@ -472,6 +519,8 @@ True True + True + True True @@ -479,6 +528,7 @@ True True True + True True True True @@ -488,16 +538,20 @@ True True True + True True True + True + True True True + True True - True + True True @@ -509,6 +563,7 @@ True True True + True True True @@ -522,12 +577,15 @@ True True True + True True + True True True True + True True True @@ -535,6 +593,7 @@ True True True + True True True @@ -547,8 +606,8 @@ True True True - True - True + + True True @@ -584,6 +643,7 @@ True True True + True @@ -592,5 +652,6 @@ True True + True True True \ No newline at end of file diff --git a/sample/WebApi.Test.Unit/Controllers/GarnetController.cs b/sample/WebApi.Test.Unit/Controllers/GarnetController.cs index 38a67de9..fee91707 100644 --- a/sample/WebApi.Test.Unit/Controllers/GarnetController.cs +++ b/sample/WebApi.Test.Unit/Controllers/GarnetController.cs @@ -5,7 +5,9 @@ namespace WebApi.Test.Unit.Controllers; /// -[Route("api/[controller]"), ApiController, ApiGroup("GarnetTest", "v1", "Garnet的基本使用")] +[Route("api/[controller]")] +[ApiController] +[ApiGroup("GarnetTest", "v1", "Garnet的基本使用")] public class GarnetController : ControllerBase { private readonly IDatabase _rdb; diff --git a/sample/WebApi.Test.Unit/Controllers/GridFSController.cs b/sample/WebApi.Test.Unit/Controllers/GridFSController.cs index 52800e22..1a8ddf7a 100644 --- a/sample/WebApi.Test.Unit/Controllers/GridFSController.cs +++ b/sample/WebApi.Test.Unit/Controllers/GridFSController.cs @@ -14,7 +14,9 @@ namespace WebApi.Test.Unit.Controllers; /// /// GridFS控制器,当引入Extension后,请使用Extension版本的API /// -[ApiController, Route("api/[controller]"), ApiGroup("MongoFS", "v1", "MongoDB GridFS")] +[ApiController] +[Route("api/[controller]")] +[ApiGroup("MongoFS", "v1", "MongoDB GridFS")] public class GridFSController(GridFSBucket bucket) : ControllerBase { /// diff --git a/sample/WebApi.Test.Unit/Controllers/HttpClientGridFSController.cs b/sample/WebApi.Test.Unit/Controllers/HttpClientGridFSController.cs index 3de10775..dcdf6c2f 100644 --- a/sample/WebApi.Test.Unit/Controllers/HttpClientGridFSController.cs +++ b/sample/WebApi.Test.Unit/Controllers/HttpClientGridFSController.cs @@ -6,7 +6,9 @@ namespace WebApi.Test.Unit.Controllers; /// /// 测试HttpClient上传文件的问题复现 /// -[Route("api/[controller]"), ApiController, ApiGroup("GridFSTest", "v1", "HttpClientGridFSController")] +[Route("api/[controller]")] +[ApiController] +[ApiGroup("GridFSTest", "v1", "HttpClientGridFSController")] public class HttpClientGridFSController : ControllerBase { /// diff --git a/sample/WebApi.Test.Unit/Controllers/KeyedServiceTestController.cs b/sample/WebApi.Test.Unit/Controllers/KeyedServiceTestController.cs index 26285778..f3f8b413 100644 --- a/sample/WebApi.Test.Unit/Controllers/KeyedServiceTestController.cs +++ b/sample/WebApi.Test.Unit/Controllers/KeyedServiceTestController.cs @@ -9,7 +9,9 @@ namespace WebApi.Test.Unit.Controllers; /// /// KeyedServiceTest /// -[Route("api/[controller]"), ApiController, ApiGroup("KeyedServiceTest", "v1", "KeyedServiceTestController")] +[Route("api/[controller]")] +[ApiController] +[ApiGroup("KeyedServiceTest", "v1", "KeyedServiceTestController")] public class KeyedServiceTestController(IServiceProvider sp, IKeyedServiceTest kst2) : ControllerBase { /// diff --git a/sample/WebApi.Test.Unit/Controllers/MongoArrayController.cs b/sample/WebApi.Test.Unit/Controllers/MongoArrayController.cs index 304038a9..2e64a6e9 100644 --- a/sample/WebApi.Test.Unit/Controllers/MongoArrayController.cs +++ b/sample/WebApi.Test.Unit/Controllers/MongoArrayController.cs @@ -14,7 +14,9 @@ namespace WebApi.Test.Unit.Controllers; /// Mongo的数组对象操作 /// /// -[Route("api/[controller]"), ApiController, ApiGroup("MongoTest", "v1", "MongoDB一些测试")] +[Route("api/[controller]")] +[ApiController] +[ApiGroup("MongoTest", "v1", "MongoDB一些测试")] public class MongoArrayController(DbContext db) : ControllerBase { private readonly FilterDefinitionBuilder _bf = Builders.Filter; diff --git a/sample/WebApi.Test.Unit/Controllers/MongoLockController.cs b/sample/WebApi.Test.Unit/Controllers/MongoLockController.cs index a9628ae0..29a57e65 100644 --- a/sample/WebApi.Test.Unit/Controllers/MongoLockController.cs +++ b/sample/WebApi.Test.Unit/Controllers/MongoLockController.cs @@ -8,7 +8,9 @@ namespace WebApi.Test.Unit.Controllers; /// /// MongoDB分布式锁测试 /// -[Route("api/[controller]/[action]"), ApiController, ApiGroup("MongoLock", "v1", "基于MongoDB实现的分布式锁测试")] +[Route("api/[controller]/[action]")] +[ApiController] +[ApiGroup("MongoLock", "v1", "基于MongoDB实现的分布式锁测试")] public class MongoLockController(IMongoLockFactory lockFactory, DbContext db) : ControllerBase { /// diff --git a/sample/WebApi.Test.Unit/Controllers/MongoTestController.cs b/sample/WebApi.Test.Unit/Controllers/MongoTestController.cs index 6ac6e81a..3cdf0aad 100644 --- a/sample/WebApi.Test.Unit/Controllers/MongoTestController.cs +++ b/sample/WebApi.Test.Unit/Controllers/MongoTestController.cs @@ -13,7 +13,9 @@ namespace WebApi.Test.Unit.Controllers; /// /// 测试mongodb的一些功能 /// -[ApiController, Route("api/[controller]"), ApiGroup("MongoTest", "v1", "MongoDB一些测试")] +[ApiController] +[Route("api/[controller]")] +[ApiGroup("MongoTest", "v1", "MongoDB一些测试")] public class MongoTestController(DbContext db) : ControllerBase { private readonly FilterDefinitionBuilder bf = Builders.Filter; @@ -81,7 +83,8 @@ public Task MongoPost() /// 测试从MongoDB中取出插入的数据,再返回到Swagger查看数据JSON转换是否正常 /// /// - [HttpGet("MongoGet"), OutputCache] + [HttpGet("MongoGet")] + [OutputCache] public async Task> MongoGet() => await db.Test.Find(bf.Empty).ToListAsync(); /// diff --git a/sample/WebApi.Test.Unit/Controllers/PramsIgnoreController.cs b/sample/WebApi.Test.Unit/Controllers/PramsIgnoreController.cs index 3c1af6bd..64af618c 100644 --- a/sample/WebApi.Test.Unit/Controllers/PramsIgnoreController.cs +++ b/sample/WebApi.Test.Unit/Controllers/PramsIgnoreController.cs @@ -10,7 +10,8 @@ namespace WebApi.Test.Unit.Controllers; /// /// 测试参数隐藏 /// -[Route("api/[controller]/[action]"), ApiController] +[Route("api/[controller]/[action]")] +[ApiController] public class PramsIgnoreController : ControllerBase { /// diff --git a/sample/WebApi.Test.Unit/Controllers/RabbitBusController.cs b/sample/WebApi.Test.Unit/Controllers/RabbitBusController.cs index daf056a8..63b9ceca 100644 --- a/sample/WebApi.Test.Unit/Controllers/RabbitBusController.cs +++ b/sample/WebApi.Test.Unit/Controllers/RabbitBusController.cs @@ -9,7 +9,9 @@ namespace WebApi.Test.Unit.Controllers; /// /// 消息总线测试控制器 /// -[ApiController, Route("api/[controller]/[action]"), ApiGroup("RabbitBus", "v1", "RabbitBus Test")] +[ApiController] +[Route("api/[controller]/[action]")] +[ApiGroup("RabbitBus", "v1", "RabbitBus Test")] public class RabbitBusController(IBus ibus) : ControllerBase { /// diff --git a/sample/WebApi.Test.Unit/Controllers/ValuesController.cs b/sample/WebApi.Test.Unit/Controllers/ValuesController.cs index b24e1ac5..08ab9af6 100644 --- a/sample/WebApi.Test.Unit/Controllers/ValuesController.cs +++ b/sample/WebApi.Test.Unit/Controllers/ValuesController.cs @@ -8,7 +8,8 @@ namespace WebApi.Test.Unit.Controllers; /// /// 一些接口上的功能测试 /// -[Route("api/[controller]/[action]"), ApiController] +[Route("api/[controller]/[action]")] +[ApiController] public class ValuesController : ControllerBase { /// diff --git a/sample/WebApi.Test.Unit/Events/RabbitEvents.cs b/sample/WebApi.Test.Unit/Events/RabbitEvents.cs index 36fbe67d..7346c070 100644 --- a/sample/WebApi.Test.Unit/Events/RabbitEvents.cs +++ b/sample/WebApi.Test.Unit/Events/RabbitEvents.cs @@ -13,7 +13,8 @@ namespace WebApi.Test.Unit.Events; /// 测试HelloWorld模式消息类型 /// //[Exchange(EModel.None, queue: "hello.world")] -[Exchange(EModel.Delayed, "delayed.hello", queue: "delayed.hello.world"), QueueArg("x-message-ttl", 5000)] +[Exchange(EModel.Delayed, "delayed.hello", queue: "delayed.hello.world")] +[QueueArg("x-message-ttl", 5000)] public class HelloWorldEvent : IEvent { /// diff --git a/sample/WebApi.Test.Unit/ServiceModules/MongoModule.cs b/sample/WebApi.Test.Unit/ServiceModules/MongoModule.cs index 831b3f7e..735e66bc 100644 --- a/sample/WebApi.Test.Unit/ServiceModules/MongoModule.cs +++ b/sample/WebApi.Test.Unit/ServiceModules/MongoModule.cs @@ -2,7 +2,6 @@ using EasilyNET.AutoDependencyInjection.Modules; using EasilyNET.Mongo.AspNetCore.Serializers; using EasilyNET.Mongo.ConsoleDebug.Subscribers; -using MongoDB.Driver.Linq; namespace WebApi.Test.Unit.ServiceModules; @@ -26,8 +25,6 @@ public override void ConfigureServices(ConfigureServicesContext context) //{ // Servers = new List { new("127.0.0.1", 27018) }, // Credential = MongoCredential.CreateCredential("admin", "guest", "guest"), - // // 新版驱动使用V3版本,有可能会出现一些Linq表达式客户端函数无法执行,需要调整代码,但是工作量太大了,所以可以先使用V2兼容. - // LinqProvider = LinqProvider.V3, // // 对接 SkyAPM 的 MongoDB探针 // ClusterConfigurator = cb => cb.Subscribe(new DiagnosticsActivityEventSubscriber()) //}, c => @@ -64,7 +61,6 @@ public override void ConfigureServices(ConfigureServicesContext context) // }; // c.ClientSettings = cs => // { - // cs.LinqProvider = LinqProvider.V2; // cs.ClusterConfigurator = cb => cb.Subscribe(new ActivityEventSubscriber()); // }; //}); @@ -84,14 +80,12 @@ public override void ConfigureServices(ConfigureServicesContext context) CaptureCommandText = true })); }; - cs.LinqProvider = LinqProvider.V3; // https://www.mongodb.com/docs/drivers/csharp/current/fundamentals/logging/#log-messages-by-category //cs.LoggingSettings = new(LoggerFactory.Create(b => //{ // b.AddConfiguration(new ConfigurationBuilder().AddInMemoryCollection(new Dictionary // { // //{ "LogLevel:Default", "Debug" }, - // //{ "LogLevel:MongoDB.SDAM", "Debug" }, // { "LogLevel:MongoDB.COMMAND", "Debug" } // //{ "LogLevel:MongoDB.CONNECTION", "Debug" }, // //{ "LogLevel:MongoDB.INTERNAL.*", "Debug" }, diff --git a/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj b/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj index 047e34fa..98c63619 100644 --- a/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj +++ b/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj @@ -56,4 +56,4 @@ - + \ No newline at end of file diff --git a/test/EasilyNET.Test.Unit/DistributedLocks/LockTest.cs b/test/EasilyNET.Test.Unit/DistributedLocks/LockTest.cs index 3747a332..b2bab34f 100644 --- a/test/EasilyNET.Test.Unit/DistributedLocks/LockTest.cs +++ b/test/EasilyNET.Test.Unit/DistributedLocks/LockTest.cs @@ -2,14 +2,14 @@ using FluentAssertions; using MongoDB.Bson; using MongoDB.Driver; -using MongoDB.Driver.Linq; namespace EasilyNET.Test.Unit.DistributedLocks; /// /// 测试 /// -[TestClass, Ignore] +[TestClass] +[Ignore] public class LockTests { private readonly IMongoCollection _locks; @@ -23,8 +23,7 @@ public LockTests() var setting = new MongoClientSettings { Servers = [new("127.0.0.1", 27018)], - Credential = MongoCredential.CreateCredential("admin", "guest", "guest"), - LinqProvider = LinqProvider.V3 + Credential = MongoCredential.CreateCredential("admin", "guest", "guest") }; var client = new MongoClient(setting); var db = client.GetDatabase("locks"); diff --git a/test/EasilyNET.Test.Unit/Language/CustomIntEnumeratorTest.cs b/test/EasilyNET.Test.Unit/Language/CustomIntEnumeratorTest.cs index a715be38..4e478eb0 100644 --- a/test/EasilyNET.Test.Unit/Language/CustomIntEnumeratorTest.cs +++ b/test/EasilyNET.Test.Unit/Language/CustomIntEnumeratorTest.cs @@ -11,7 +11,9 @@ public class CustomIntEnumeratorTest /// CustomIntEnumeratorExtension Test /// /// - [TestMethod, DataRow(3), DataRow(5)] + [TestMethod] + [DataRow(3)] + [DataRow(5)] public void TestCustomIntEnumeratorExtension(int value) { foreach (var i in ..value) @@ -24,7 +26,9 @@ public void TestCustomIntEnumeratorExtension(int value) /// CustomIntEnumeratorExtension Test /// /// - [TestMethod, DataRow(3), DataRow(5)] + [TestMethod] + [DataRow(3)] + [DataRow(5)] public void OneToValue(int value) { foreach (var i in 1..value) @@ -37,7 +41,9 @@ public void OneToValue(int value) /// CustomIntEnumeratorExtension Test /// /// - [TestMethod, DataRow(3), DataRow(5)] + [TestMethod] + [DataRow(3)] + [DataRow(5)] public void OnlyValue(int value) { foreach (var i in value) diff --git a/test/EasilyNET.Test.Unit/Misc/RmbCapitalizedTest.cs b/test/EasilyNET.Test.Unit/Misc/RmbCapitalizedTest.cs index d3640c92..852f41c6 100644 --- a/test/EasilyNET.Test.Unit/Misc/RmbCapitalizedTest.cs +++ b/test/EasilyNET.Test.Unit/Misc/RmbCapitalizedTest.cs @@ -12,7 +12,8 @@ public class RmbCapitalizedTest /// /// 较小值 /// - [TestMethod, DataRow(1594.6589)] + [TestMethod] + [DataRow(1594.6589)] public void RmbCapitalizedMin(double value) { Console.WriteLine(value.ToRmb()); @@ -22,7 +23,8 @@ public void RmbCapitalizedMin(double value) /// /// 较大值 /// - [TestMethod, DataRow("1594278327421378518276358712.6589")] + [TestMethod] + [DataRow("1594278327421378518276358712.6589")] public void RmbCapitalizedMax(string value) { Console.WriteLine(value.ToRmb()); diff --git a/test/EasilyNET.Test.Unit/Randoms/RandomTest.cs b/test/EasilyNET.Test.Unit/Randoms/RandomTest.cs index e3a68968..c9c9a88a 100644 --- a/test/EasilyNET.Test.Unit/Randoms/RandomTest.cs +++ b/test/EasilyNET.Test.Unit/Randoms/RandomTest.cs @@ -5,22 +5,21 @@ namespace EasilyNET.Test.Unit.Randoms; [TestClass] public class RandomTest { - private readonly Random _random = new(); - [TestMethod] public void StrictNext_ShouldReturnValueWithinRange() { // Act - var result = _random.StrictNext(); + var result = RandomExtensions.StrictNext(); // Assert Assert.IsTrue(result is >= 0 and < int.MaxValue); } - [TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException))] + [TestMethod] + [ExpectedException(typeof(ArgumentOutOfRangeException))] public void StrictNext2_ShouldThrowArgumentOutOfRangeException_WhenStartIndexIsGreaterThanOrEqualToMaxValue() { // Act - _random.StrictNext(10, 5); + RandomExtensions.StrictNext(10, 5); } } \ No newline at end of file diff --git a/test/EasilyNET.Test.Unit/System/SnowFlakeIdTest.cs b/test/EasilyNET.Test.Unit/System/SnowFlakeIdTest.cs new file mode 100644 index 00000000..a8b989d5 --- /dev/null +++ b/test/EasilyNET.Test.Unit/System/SnowFlakeIdTest.cs @@ -0,0 +1,102 @@ +using System.Diagnostics; +using EasilyNET.Core.System; +using FluentAssertions; + +namespace EasilyNET.Test.Unit.System; + +/// +/// 测试雪花ID,只支持long类型 +/// +[TestClass] +public class SnowFlakeIdTest +{ + /// + /// + [TestMethod] + public void TestDefaultNextId() + { + var id = SnowFlakeId.Default.NextId(); + id.Should().BeGreaterThan(0); + } + + /// + /// 检测ID是不是递增的 + /// + [TestMethod] + public void TestGenerateIncreasing_Ids() + { + var lastId = 0L; + for (var i = 0; i < 100; i++) + { + var id = SnowFlakeId.Default.NextId(); + id.Should().BeGreaterThan(lastId); + lastId = id; + } + } + + /// + /// 生成唯一ID测试 + /// + [TestMethod] + [Ignore] + public void GenerateOnlyUniqueIds() + { + var set = new HashSet(); + const int N = 2000000; + for (var i = 0; i < N; i++) + { + var id = SnowFlakeId.Default.NextId(); + if (!set.Add(id)) + { + Debug.WriteLine($"重复ID{id}"); + } + } + set.Count.Should().Be(N); + } + + /// + /// Task生成唯一ID测试 + /// + [TestMethod] + [Ignore] + public void GenerateOnlyUniqueTaskIds() + { + var set = new HashSet(); + const int N = 2000000; + var lockObject = new Lock(); + const int numberOfThreads = 10; + Parallel.For(0, numberOfThreads, _ => + { + for (var j = 0; j < N; j++) + { + var id = SnowFlakeId.Default.NextId(); + lock (lockObject) + { + if (!set.Add(id)) + { + Debug.WriteLine($"重复ID{id}"); + } + } + } + }); + set.Count.Should().Be(N * numberOfThreads); + } + + /// + /// + [TestMethod] + public void It_should_properly_mask_worker_id() + { + // Arrange + const int workerId = 123; + SnowFlakeId.SetDefaultSnowFlakeId(new(workerId)); + const long expectedMaskedWorkerId = workerId & 0xFFF; // 0xFFF is the mask for 12 bits + + // Act + var generatedId = SnowFlakeId.Default.NextId(); + var maskedWorkerId = (generatedId >> 10) & 0xFFF; // Shift and mask to get workerId + + // Assert + Assert.AreEqual(expectedMaskedWorkerId, maskedWorkerId); + } +} \ No newline at end of file diff --git a/test/EasilyNET.Test.Unit/System/SnowIdTest.cs b/test/EasilyNET.Test.Unit/System/SnowIdTest.cs new file mode 100644 index 00000000..119f55d3 --- /dev/null +++ b/test/EasilyNET.Test.Unit/System/SnowIdTest.cs @@ -0,0 +1,74 @@ +using EasilyNET.Core.Misc; +using EasilyNET.Core.System; +using FluentAssertions; + +namespace EasilyNET.Test.Unit.System; + +/// +/// 测试雪花ID,其实是MongoDB的ObjectId,用来对没有使用Mongodb的情况下,获取雪花ID的一种方案. +/// +[TestClass] +public class SnowIdTest(TestContext context) +{ + /// + /// 测试生成的 SnowId 是否唯一 + /// + [TestMethod] + public void TestSnowIdUniqueness() + { + var snow1 = SnowId.GenerateNewId(); + var snow2 = SnowId.GenerateNewId(); + context.WriteLine($"snow1: {snow1}"); + context.WriteLine($"snow2: {snow2}"); + var equal = snow1 == snow2 || snow1.Equals(snow2); + equal.Should().BeFalse(); + } + + /// + /// 测试 SnowId 的比较功能 + /// + [TestMethod] + public void TestSnowIdComparison() + { + var snow1 = SnowId.GenerateNewId(); + var snow2 = SnowId.GenerateNewId(); + var comparison = snow2.CompareTo(snow1); + comparison.Should().Be(1); + } + + /// + /// 测试 SnowId 的解析功能 + /// + [TestMethod] + public void TestSnowIdParsing() + { + var snow1 = SnowId.GenerateNewId(); + var snow1String = snow1.ToString(); + var parsedSnow1 = SnowId.Parse(snow1String); + snow1.Should().Be(parsedSnow1); + } + + /// + /// 测试 SnowId 的字节数组转换功能 + /// + [TestMethod] + public void TestSnowIdByteArrayConversion() + { + var snow1 = SnowId.GenerateNewId(); + var byteArray = snow1.ToByteArray(); + var snowFromBytes = new SnowId(byteArray); + snow1.Should().Be(snowFromBytes); + } + + /// + /// 测试 SnowId 的时间戳和创建时间 + /// + [TestMethod] + public void TestSnowIdTimestampAndCreationTime() + { + var snow1 = SnowId.GenerateNewId(); + var timestamp = snow1.Timestamp; + var creationTime = snow1.CreationTime; + creationTime.Should().Be(DateTimeStampExtension.UnixEpoch.AddSeconds((uint)timestamp)); + } +} \ No newline at end of file