## 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.
130 lines
5 KiB
C#
130 lines
5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
using Server;
|
|
using Server.Engines.Spawners;
|
|
using Server.Regions;
|
|
using Xunit;
|
|
|
|
namespace UOContent.Tests.Engines.Spawners.Json;
|
|
|
|
[Collection("Sequential UOContent Tests")]
|
|
public class SpawnerDtoRoundTripTests
|
|
{
|
|
[Fact]
|
|
public void Spawner_NonSquareBounds_WritesSpawnBounds_RoundTrips()
|
|
{
|
|
Spawner original = null;
|
|
BaseSpawner rebuilt = null;
|
|
try
|
|
{
|
|
// Bounds centered on (102,102), placed at (105,105) -> not a homeRange square.
|
|
original = new Spawner(2, TimeSpan.FromMinutes(3), TimeSpan.FromMinutes(7), 0,
|
|
new Rectangle3D(100, 100, 0, 5, 5, 0), "Fisherman");
|
|
original.MoveToWorld(new Point3D(105, 105, 0), Map.Felucca);
|
|
|
|
var json = JsonSerializer.Serialize(new List<SpawnerDto> { original.ToDto() }, SpawnerJsonSerializer.Options);
|
|
Assert.Contains("\"$type\": \"Spawner\"", json);
|
|
Assert.Contains("\"count\": 2", json);
|
|
Assert.Contains("spawnBounds", json);
|
|
Assert.DoesNotContain("homeRange", json);
|
|
|
|
var dtos = JsonSerializer.Deserialize<List<SpawnerDto>>(json, SpawnerJsonSerializer.Options);
|
|
rebuilt = Assert.Single(dtos).ToSpawner();
|
|
var s = Assert.IsType<Spawner>(rebuilt);
|
|
Assert.Equal(2, s.Count);
|
|
Assert.Equal(TimeSpan.FromMinutes(3), s.MinDelay);
|
|
Assert.Equal(new Rectangle3D(100, 100, 0, 5, 5, 0), s.SpawnBounds);
|
|
Assert.Equal("Fisherman", Assert.Single(s.Entries).SpawnedName);
|
|
}
|
|
finally
|
|
{
|
|
rebuilt?.Delete();
|
|
original?.Delete();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Spawner_WritesMandatory_OmitsOptionalDefaults()
|
|
{
|
|
Spawner original = null;
|
|
try
|
|
{
|
|
// Default delays (5/10), team 0, default maxSpawnAttempts.
|
|
original = new Spawner("Fisherman");
|
|
original.MoveToWorld(new Point3D(110, 110, 0), Map.Felucca);
|
|
var json = JsonSerializer.Serialize(new List<SpawnerDto> { original.ToDto() }, SpawnerJsonSerializer.Options);
|
|
|
|
// Mandatory — always written, even at default.
|
|
Assert.Contains("\"guid\":", json);
|
|
Assert.Contains("minDelay", json);
|
|
Assert.Contains("maxDelay", json);
|
|
|
|
// Optional defaults — omitted.
|
|
Assert.DoesNotContain("\"team\"", json);
|
|
Assert.DoesNotContain("maxSpawnAttempts", json);
|
|
Assert.DoesNotContain("spawnLocationIsHome", json);
|
|
}
|
|
finally
|
|
{
|
|
original?.Delete();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void RegionSpawner_RoundTrips_RegionByName()
|
|
{
|
|
var region = new BaseRegion("DtoTestRegion", Map.Felucca, 50, new Rectangle3D(1400, 1670, 0, 40, 40, 0));
|
|
region.Register();
|
|
RegionSpawner original = null;
|
|
BaseSpawner rebuilt = null;
|
|
try
|
|
{
|
|
original = new RegionSpawner("Fisherman") { SpawnRegion = region };
|
|
original.MoveToWorld(new Point3D(1416, 1683, 0), Map.Felucca);
|
|
var json = JsonSerializer.Serialize(new List<SpawnerDto> { original.ToDto() }, SpawnerJsonSerializer.Options);
|
|
Assert.Contains("\"$type\": \"RegionSpawner\"", json);
|
|
Assert.Contains("DtoTestRegion", json);
|
|
Assert.DoesNotContain("homeRange", json);
|
|
Assert.DoesNotContain("spawnBounds", json);
|
|
|
|
var dtos = JsonSerializer.Deserialize<List<SpawnerDto>>(json, SpawnerJsonSerializer.Options);
|
|
rebuilt = Assert.Single(dtos).ToSpawner();
|
|
Assert.Equal("DtoTestRegion", Assert.IsType<RegionSpawner>(rebuilt).SpawnRegion?.Name);
|
|
}
|
|
finally
|
|
{
|
|
rebuilt?.Delete();
|
|
original?.Delete();
|
|
region.Unregister();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ProximitySpawner_RoundTrips_Fields()
|
|
{
|
|
ProximitySpawner original = null;
|
|
BaseSpawner rebuilt = null;
|
|
try
|
|
{
|
|
original = new ProximitySpawner("Fisherman") { TriggerRange = 4, InstantFlag = true, SpawnMessage = 500000 };
|
|
original.MoveToWorld(new Point3D(120, 120, 0), Map.Felucca);
|
|
var json = JsonSerializer.Serialize(new List<SpawnerDto> { original.ToDto() }, SpawnerJsonSerializer.Options);
|
|
Assert.Contains("\"$type\": \"ProximitySpawner\"", json);
|
|
Assert.Contains("\"triggerRange\": 4", json);
|
|
Assert.Contains("\"instant\": true", json);
|
|
|
|
var dtos = JsonSerializer.Deserialize<List<SpawnerDto>>(json, SpawnerJsonSerializer.Options);
|
|
rebuilt = Assert.Single(dtos).ToSpawner();
|
|
var p = Assert.IsType<ProximitySpawner>(rebuilt);
|
|
Assert.Equal(4, p.TriggerRange);
|
|
Assert.True(p.InstantFlag);
|
|
Assert.Equal(500000, p.SpawnMessage.Number);
|
|
}
|
|
finally
|
|
{
|
|
rebuilt?.Delete();
|
|
original?.Delete();
|
|
}
|
|
}
|
|
}
|