## 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.
123 lines
3.4 KiB
C#
123 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Xunit;
|
|
|
|
namespace Server.Tests;
|
|
|
|
[Collection("Sequential Server Tests")]
|
|
public class TestStringHelpers
|
|
{
|
|
[Theory]
|
|
[InlineData("this is not capitalized", "This Is Not Capitalized")]
|
|
[InlineData("", "")]
|
|
[InlineData(null, null)]
|
|
[InlineData("nospaceshere", "Nospaceshere")]
|
|
[InlineData("harry the fireman", "Harry the Fireman")]
|
|
public void TestCapitalize(string original, string capitalized)
|
|
{
|
|
var actual = original.Capitalize();
|
|
|
|
Assert.Equal(capitalized, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("we are testing removing spaces", " ", "wearetestingremovingspaces", StringComparison.Ordinal)]
|
|
[InlineData("", " ", "", StringComparison.Ordinal)]
|
|
[InlineData(null, null, null, StringComparison.Ordinal)]
|
|
public void TestRemove(string original, string separator, string removed, StringComparison comparison)
|
|
{
|
|
var actual = original.AsSpan().Remove(separator, comparison);
|
|
|
|
Assert.Equal(removed, actual);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("this is a sentence that will probably wrap around a few times because it is long", 10, 6)]
|
|
[InlineData("An Unnamed House", 10, 6)]
|
|
[InlineData("Batville", 10, 6)]
|
|
[InlineData("Bald's Shop", 10, 6)]
|
|
[InlineData(
|
|
"Something ThatIsVeryLongAndShouldBe broken up",
|
|
10, 6,
|
|
"Something", "ThatIsVery", "LongAndSho", "uldBe", "broken up"
|
|
)]
|
|
public void TestWrap(string sentence, int perLine, int maxLines, params string[] customExpected)
|
|
{
|
|
var expected = customExpected.Length > 0
|
|
? customExpected
|
|
: OldWrap(sentence, perLine, maxLines).ToArray();
|
|
var actual = sentence.Wrap(perLine, maxLines).ToArray();
|
|
|
|
Assert.Equal(expected, actual);
|
|
}
|
|
|
|
// The old wrap function from HouseGump/HouseGumpAOS
|
|
private static List<string> OldWrap(string value, int startIndex, int maxLines)
|
|
{
|
|
if (value == null || (value = value.Trim()).Length <= 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var values = value.Split(' ');
|
|
var list = new List<string>();
|
|
var current = "";
|
|
|
|
for (var i = 0; i < values.Length; ++i)
|
|
{
|
|
var val = values[i];
|
|
|
|
var v = current.Length == 0 ? val : $"{current} {val}";
|
|
|
|
if (v.Length < startIndex)
|
|
{
|
|
current = v;
|
|
}
|
|
else if (v.Length == startIndex)
|
|
{
|
|
list.Add(v);
|
|
|
|
if (list.Count == maxLines)
|
|
{
|
|
return list;
|
|
}
|
|
|
|
current = "";
|
|
}
|
|
else if (val.Length <= startIndex)
|
|
{
|
|
list.Add(current);
|
|
|
|
if (list.Count == maxLines)
|
|
{
|
|
return list;
|
|
}
|
|
|
|
current = val;
|
|
}
|
|
else
|
|
{
|
|
while (v.Length >= startIndex)
|
|
{
|
|
list.Add(v[..startIndex]);
|
|
|
|
if (list.Count == maxLines)
|
|
{
|
|
return list;
|
|
}
|
|
|
|
v = v[startIndex..];
|
|
}
|
|
|
|
current = v;
|
|
}
|
|
}
|
|
|
|
if (current.Length > 0)
|
|
{
|
|
list.Add(current);
|
|
}
|
|
|
|
return list;
|
|
}
|
|
}
|