Files
Cj c16c988fda Merge pull request #539 from CJ-SPT/test-mod
Intoduce test mod and restructure test suites into their own solution folder
2025-08-09 19:26:06 +00:00

36 lines
1.0 KiB
C#

using NUnit.Framework;
using SPTarkov.Server.Core.Extensions;
using SPTarkov.Server.Core.Models.Common;
namespace UnitTests.Tests.Utils;
/// <summary>
/// Unit tests for the <see cref="MongoId"/> struct.
/// </summary>
[TestFixture]
public class MongoIdTests
{
/// <summary>
/// Test that generates 1000 <see cref="MongoId"/> and ensures they are all valid. <br/>
/// Validity is checked by ensuring the ID is non-empty, exactly 24 characters, and matches the expected format.
/// </summary>
[Test]
public void Generate_ShouldProduceValidMongoIds()
{
var invalidIds = new List<string>();
for (var i = 0; i < 1000; i++)
{
var id = new MongoId();
var idStr = id.ToString();
if (string.IsNullOrWhiteSpace(idStr) || idStr.Length != 24 || !id.IsValidMongoId())
{
invalidIds.Add(idStr);
}
}
Assert.AreEqual(0, invalidIds.Count, $"Invalid MongoIds found: {string.Join(", ", invalidIds)}");
}
}