This commit is contained in:
2026-03-25 14:55:34 +08:00
commit 2c44b3a4b2
131 changed files with 7453 additions and 0 deletions

View File

@@ -0,0 +1 @@
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]

View File

@@ -0,0 +1,53 @@
using Microsoft.Extensions.Logging;
using StopShopping.Services.Implementions;
namespace StopShopping.Services.Test;
[TestClass]
public sealed class SerialNoGeneratorTests
{
[ClassInitialize]
public static void Init(TestContext testContext)
{
_serialNoGenerator = new SerialNoGenerator(
LoggerFactory.Create(options => options.AddConsole()).CreateLogger<SerialNoGenerator>());
_nanoidGenerator = new NanoidSerialNoGenerator();
}
private static SerialNoGenerator? _serialNoGenerator;
private static NanoidSerialNoGenerator? _nanoidGenerator;
[TestMethod]
[DataRow(10)]
public void Gen_Right_Count(int count)
{
List<string> serialNos = [];
for (var i = 0; i < count; i++)
{
var no = _serialNoGenerator?.GenerateRequestNo();
if (!string.IsNullOrWhiteSpace(no))
serialNos.Add(no);
}
serialNos.ForEach(s => Console.WriteLine("{0} - {1}", s, Convert.ToString(long.Parse(s[1..]), toBase: 2)));
Assert.HasCount(count, serialNos);
}
[TestMethod]
[DataRow(10)]
public void Nanoid_Gen_Right_Count(int count)
{
List<string> serialNos = [];
for (var i = 0; i < count; i++)
{
var no = _nanoidGenerator?.GenerateRequestNo();
if (!string.IsNullOrWhiteSpace(no))
serialNos.Add(no);
}
serialNos.ForEach(s => Console.WriteLine(s));
Assert.HasCount(count, serialNos);
}
}

View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSTest" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StopShopping.Services\StopShopping.Services.csproj" />
</ItemGroup>
</Project>