29 lines
719 B
C#
29 lines
719 B
C#
using backend.Pairing;
|
|
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace backend.tests;
|
|
|
|
public class PairingServiceTests
|
|
{
|
|
[Fact]
|
|
public void Generated_codes_use_only_safe_alphabet_and_are_8_chars()
|
|
{
|
|
var svc = new PairingService();
|
|
for (var i = 0; i < 50; i++)
|
|
{
|
|
var code = svc.GenerateCode();
|
|
code.Length.Should().Be(8);
|
|
code.Should().MatchRegex("^[A-HJ-KM-NP-Z2-9]+$");
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Generated_codes_are_not_all_identical()
|
|
{
|
|
var svc = new PairingService();
|
|
var codes = Enumerable.Range(0, 20).Select(_ => svc.GenerateCode()).ToHashSet();
|
|
codes.Count.Should().BeGreaterThan(15);
|
|
}
|
|
}
|