✨
This commit is contained in:
1
StopShopping.Services.Test/MSTestSettings.cs
Normal file
1
StopShopping.Services.Test/MSTestSettings.cs
Normal file
@@ -0,0 +1 @@
|
||||
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
|
||||
53
StopShopping.Services.Test/SerialNoGeneratorTests.cs
Normal file
53
StopShopping.Services.Test/SerialNoGeneratorTests.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
22
StopShopping.Services.Test/StopShopping.Services.Test.csproj
Normal file
22
StopShopping.Services.Test/StopShopping.Services.Test.csproj
Normal 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>
|
||||
Reference in New Issue
Block a user