## 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.
118 lines
3.7 KiB
C#
118 lines
3.7 KiB
C#
using System.Collections.Generic;
|
|
using Server.Mobiles;
|
|
using Xunit;
|
|
|
|
namespace Server.Tests;
|
|
|
|
/// <summary>
|
|
/// Pins the looting-rights rules that the inline damage entry list has to keep producing: the
|
|
/// returned stores are sorted by damage descending, the first (least recent) damager takes the
|
|
/// 1.25x bonus, the hitsMax band decides who clears the threshold, and a pet's damage is credited
|
|
/// to its damage master rather than to the pet.
|
|
/// </summary>
|
|
[Collection("Sequential UOContent Tests")]
|
|
public class LootingRightsTests
|
|
{
|
|
private class TestMobile : Mobile
|
|
{
|
|
}
|
|
|
|
private class PetMobile : Mobile
|
|
{
|
|
public Mobile Master { get; set; }
|
|
|
|
public override Mobile GetDamageMaster(Mobile damagee) => Master;
|
|
}
|
|
|
|
// GetLootingRights only ever credits mobiles flagged as players.
|
|
private static TestMobile NewPlayer() => new() { Player = true };
|
|
|
|
private static DamageStore FindStore(List<DamageStore> rights, Mobile m)
|
|
{
|
|
for (var i = 0; i < rights.Count; i++)
|
|
{
|
|
if (rights[i].m_Mobile == m)
|
|
{
|
|
return rights[i];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
[Fact]
|
|
public void TwoPlayerDamagers_SortDescending_AndTheFirstDamagerTakesTheBonus()
|
|
{
|
|
var victim = new TestMobile();
|
|
var first = NewPlayer();
|
|
var second = NewPlayer();
|
|
|
|
try
|
|
{
|
|
victim.RegisterDamage(100, first);
|
|
victim.RegisterDamage(40, second); // second is the most recent, first is the "first damager"
|
|
|
|
// hitsMax < 200 puts the bar at topDamage / 2.
|
|
var rights = BaseCreature.GetLootingRights(victim.DamageEntries, 100);
|
|
|
|
Assert.Equal(2, rights.Count);
|
|
|
|
// Sorted by damage descending.
|
|
Assert.True(rights[0].m_Damage >= rights[1].m_Damage);
|
|
Assert.Same(first, rights[0].m_Mobile);
|
|
Assert.Same(second, rights[1].m_Mobile);
|
|
|
|
// The first damager - the least recent entry - gets the 1.25x bonus; nobody else does.
|
|
Assert.Equal(125, rights[0].m_Damage);
|
|
Assert.Equal(40, rights[1].m_Damage);
|
|
|
|
// topDamage 125 / 2 = 62, so 40 is below the bar.
|
|
Assert.True(rights[0].m_HasRight);
|
|
Assert.False(rights[1].m_HasRight);
|
|
}
|
|
finally
|
|
{
|
|
victim.Delete();
|
|
first.Delete();
|
|
second.Delete();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void PetDamage_CreditsTheMaster_NotThePet()
|
|
{
|
|
var victim = new TestMobile();
|
|
var master = NewPlayer();
|
|
var pet = new PetMobile { Master = master };
|
|
var wild = new TestMobile(); // no damage master, and not a player
|
|
|
|
try
|
|
{
|
|
victim.RegisterDamage(50, pet);
|
|
victim.RegisterDamage(20, wild);
|
|
|
|
var rights = BaseCreature.GetLootingRights(victim.DamageEntries, 100);
|
|
|
|
// The master is credited through the entry's Responsible sub-entry, and is the only one.
|
|
Assert.Single(rights);
|
|
|
|
var masterStore = FindStore(rights, master);
|
|
Assert.NotNull(masterStore);
|
|
Assert.Equal(62, masterStore.m_Damage); // 50, then the first-damager 1.25x bonus
|
|
Assert.True(masterStore.m_HasRight);
|
|
|
|
// The pet's own damage was fully handed to the master, so it earns no store.
|
|
Assert.Null(FindStore(rights, pet));
|
|
|
|
// A non-player damager earns nothing even when its damage was never reassigned.
|
|
Assert.Null(FindStore(rights, wild));
|
|
}
|
|
finally
|
|
{
|
|
victim.Delete();
|
|
master.Delete();
|
|
pet.Delete();
|
|
wild.Delete();
|
|
}
|
|
}
|
|
}
|