ModernUO/Projects/UOContent.Tests/Tests/Misc/NameVerificationTests.cs
Kamron Batman 9a25054809
test: remove trivial, duplicate and content-value tests (#2721)
## Summary
Many tests proved a specific change when it landed but don't need to run on every CI build forever. This removes **202 test methods and 9 files: 313 test cases, 2,247 → 1,934**. UOContent.Tests drops from about 14s to about 5s locally.

Removed:
- **Tautologies.** Asserting a constant, a constructor readback or a trivial getter, or testing BCL behavior.
- **Exact duplicates** of a surviving test on the same code path.
- **Obsolete regressions** whose failure can no longer be expressed.
- **Game-content values** shard owners customize (era drop rates, loot and skill tables, single-creature tuning). Each customization would otherwise force a test fix.

## How it was decided
1. Every test was classified, with a reason, by a per-shard sweep over all 287 test files.
2. Each proposed deletion was then checked by a second, adversarial reviewer against the surviving tests and the production code.
3. Anything that was the only coverage of a separate code path was **kept**, even where it looked like a duplicate. Examples: the unsigned `SpanReader`/`SpanWriter` methods, the at-location versus bounds enumerators, null-map enumerables, the security filters, archive-journal state transitions. About 130 proposed deletions were rejected this way.

Whole files removed:
- `FishingTests`, apart from 3 tests: the map-edge scan, serpent cleanup, and SOS chest consumption. The SOS test now stops at the first chest instead of measuring a catch rate. The multi-million-cast rate simulations are gone.
- `LordOaksTests` and `MeerEnragedTests` (single-creature tests).
- `AutoArchiveHelperTests`, `JsonDiscoverableTypeAttributeTests`, `DecimalSerializationTests` and `EnumConversionTests` (tautologies, or tests of their own local helpers).
- `NetworkStatsTests`.
- `MigratedDataLoadTests` (a subset of `AllSpawnFilesLoadTests`).
- `SpawnerFixtureCapture`: a capture tool, not a test, and its `version == 12` assert can no longer pass. The `.bin` fixtures it produced stay.

## Tests
- Server.Tests: 811 pass.
- UOContent.Tests: 1,123 pass.

A follow-up PR, stacked on this one, fixes how the remaining tests behave: shared state, CI-vacuous tests, harness duplication.
2026-10-18 20:08:19 -07:00

122 lines
3.4 KiB
C#

using System.Buffers;
using Server.Misc;
using Xunit;
namespace Server.Tests;
public class NameVerificationTests
{
[Theory]
[InlineData("John")]
[InlineData("Mary Ann")]
[InlineData("Bob-Jones")]
[InlineData("O'Malley")]
public void ValidatePlayerName_ValidNames_ReturnsTrue(string name)
{
Assert.True(NameVerification.ValidatePlayerName(name));
}
[Theory]
[InlineData("Mrs-Smith")]
[InlineData("Mr. Whiskers")]
[InlineData("Dog123")]
public void ValidatePetName_InvalidNames_ReturnsFalse(string name)
{
Assert.False(NameVerification.ValidatePetName(name));
}
[Theory]
[InlineData("Blacksmith12")]
[InlineData("Baker")]
[InlineData("Innkeeper")]
public void ValidateVendorName_ValidNames_ReturnsTrue(string name)
{
Assert.True(NameVerification.ValidateVendorName(name));
}
[Theory]
[InlineData("Blacksmith 123")]
[InlineData("Baker-Smith")]
[InlineData("*Innkeeper*")]
public void ValidateVendorName_ValidNames_ReturnsFalse(string name)
{
Assert.False(NameVerification.ValidateVendorName(name));
}
[Fact]
public void Validate_MinimumLengthName_ReturnsTrue()
{
Assert.True(NameVerification.Validate("Ab", 2, 16, true, false));
}
[Fact]
public void Validate_MaximumLengthName_ReturnsTrue()
{
Assert.True(NameVerification.Validate("AbcdefghijklmnopqrsT", 1, 20, true, true));
}
[Fact]
public void Validate_MaxExceptions_ReturnsTrue()
{
var exceptions = SearchValues.Create(' ', '-', '.');
Assert.True(NameVerification.Validate("A-B.C D", 2, 16, true, false, false, 3, exceptions));
}
[Fact]
public void Validate_BoundaryOfDisallowedWord_ReturnsTrueWhenNotActuallyDisallowed()
{
// "ass" is in disallowed, but "class" has proper boundaries
Assert.True(NameVerification.ValidatePlayerName("Class"));
}
// Negative Tests
[Fact]
public void Validate_EmptyName_ReturnsFalse()
{
Assert.False(NameVerification.Validate("", 1, 20, true, true));
}
[Fact]
public void Validate_TooShortName_ReturnsFalse()
{
Assert.False(NameVerification.Validate("A", 2, 16, true, false));
}
[Fact]
public void Validate_TooLongName_ReturnsFalse()
{
Assert.False(NameVerification.Validate("AbcdefghijklmnopqrstuvwxyzABCDEF", 2, 16, true, false));
}
[Theory]
[InlineData("ass")]
[InlineData("GodDamn Fine")]
[InlineData("Fuck")]
public void Validate_DisallowedWords_ReturnsFalse(string name)
{
Assert.False(NameVerification.ValidatePlayerName(name));
}
[Theory]
[InlineData("GMJohn")]
[InlineData("LordBob")]
[InlineData("SeerMagic")]
public void Validate_DisallowedPrefixes_ReturnsFalse(string name)
{
Assert.False(NameVerification.ValidatePlayerName(name));
}
[Fact]
public void Validate_TooManyExceptions_ReturnsFalse()
{
var exceptions = SearchValues.Create(' ', '-', '.');
Assert.False(NameVerification.Validate("A-B.C D-E", 2, 16, true, false, false, 1, exceptions));
}
[Fact]
public void Validate_ExceptionAtStartWhenNotAllowed_ReturnsFalse()
{
var exceptions = SearchValues.Create(' ', '-', '.');
Assert.False(NameVerification.Validate("-John", 2, 16, true, false, true, 1, exceptions));
}
}