From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Sat, 8 Mar 2025 02:37:26 +0000 (+0000) Subject: Add AssertMultiple to ContrabandTest (#35662) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=cca537fb33fd424257d7930386a08901b9a0065c;p=space-station-14.git Add AssertMultiple to ContrabandTest (#35662) * add AssertMultiple to ContrabandTest * do the same for magazine visuals test * :trollface: --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- diff --git a/Content.IntegrationTests/Tests/ContrabandTest.cs b/Content.IntegrationTests/Tests/ContrabandTest.cs index ebd6afa7ef..a33e7c2067 100644 --- a/Content.IntegrationTests/Tests/ContrabandTest.cs +++ b/Content.IntegrationTests/Tests/ContrabandTest.cs @@ -17,23 +17,26 @@ public sealed class ContrabandTest await client.WaitAssertion(() => { - foreach (var proto in protoMan.EnumeratePrototypes()) + Assert.Multiple(() => { - if (proto.Abstract || pair.IsTestPrototype(proto)) - continue; + foreach (var proto in protoMan.EnumeratePrototypes()) + { + if (proto.Abstract || pair.IsTestPrototype(proto)) + continue; - if (!proto.TryGetComponent(out var contraband, componentFactory)) - continue; + if (!proto.TryGetComponent(out var contraband, componentFactory)) + continue; - Assert.That(protoMan.TryIndex(contraband.Severity, out var severity, false), - @$"{proto.ID} has a ContrabandComponent with a unknown severity."); + Assert.That(protoMan.TryIndex(contraband.Severity, out var severity, false), + @$"{proto.ID} has a ContrabandComponent with a unknown severity."); - if (!severity.ShowDepartmentsAndJobs) - continue; + if (!severity.ShowDepartmentsAndJobs) + continue; - Assert.That(contraband.AllowedDepartments.Count + contraband.AllowedJobs.Count, Is.Not.EqualTo(0), - @$"{proto.ID} has a ContrabandComponent with ShowDepartmentsAndJobs but no allowed departments or jobs."); - } + Assert.That(contraband.AllowedDepartments.Count + contraband.AllowedJobs.Count, Is.Not.EqualTo(0), + @$"{proto.ID} has a ContrabandComponent with ShowDepartmentsAndJobs but no allowed departments or jobs."); + } + }); }); await pair.CleanReturnAsync(); diff --git a/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs b/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs index f0f3b72d8d..fb0c67afd7 100644 --- a/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs +++ b/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs @@ -23,46 +23,49 @@ public sealed class MagazineVisualsSpriteTest await client.WaitAssertion(() => { - foreach (var proto in protoMan.EnumeratePrototypes()) + Assert.Multiple(() => { - if (proto.Abstract || pair.IsTestPrototype(proto)) - continue; + foreach (var proto in protoMan.EnumeratePrototypes()) + { + if (proto.Abstract || pair.IsTestPrototype(proto)) + continue; - if (!proto.TryGetComponent(out var visuals, componentFactory)) - continue; + if (!proto.TryGetComponent(out var visuals, componentFactory)) + continue; - Assert.That(proto.TryGetComponent(out var sprite, componentFactory), - @$"{proto.ID} has MagazineVisualsComponent but no SpriteComponent."); - Assert.That(proto.HasComponent(componentFactory), - @$"{proto.ID} has MagazineVisualsComponent but no AppearanceComponent."); + Assert.That(proto.TryGetComponent(out var sprite, componentFactory), + @$"{proto.ID} has MagazineVisualsComponent but no SpriteComponent."); + Assert.That(proto.HasComponent(componentFactory), + @$"{proto.ID} has MagazineVisualsComponent but no AppearanceComponent."); - var toTest = new List<(int, string)>(); - if (sprite.LayerMapTryGet(GunVisualLayers.Mag, out var magLayerId)) - toTest.Add((magLayerId, "")); - if (sprite.LayerMapTryGet(GunVisualLayers.MagUnshaded, out var magUnshadedLayerId)) - toTest.Add((magUnshadedLayerId, "-unshaded")); + var toTest = new List<(int, string)>(); + if (sprite.LayerMapTryGet(GunVisualLayers.Mag, out var magLayerId)) + toTest.Add((magLayerId, "")); + if (sprite.LayerMapTryGet(GunVisualLayers.MagUnshaded, out var magUnshadedLayerId)) + toTest.Add((magUnshadedLayerId, "-unshaded")); - Assert.That(toTest, Is.Not.Empty, - @$"{proto.ID} has MagazineVisualsComponent but no Mag or MagUnshaded layer map."); + Assert.That(toTest, Is.Not.Empty, + @$"{proto.ID} has MagazineVisualsComponent but no Mag or MagUnshaded layer map."); - var start = visuals.ZeroVisible ? 0 : 1; - foreach (var (id, midfix) in toTest) - { - Assert.That(sprite.TryGetLayer(id, out var layer)); - var rsi = layer.ActualRsi; - for (var i = start; i < visuals.MagSteps; i++) + var start = visuals.ZeroVisible ? 0 : 1; + foreach (var (id, midfix) in toTest) { - var state = $"{visuals.MagState}{midfix}-{i}"; - Assert.That(rsi.TryGetState(state, out _), - @$"{proto.ID} has MagazineVisualsComponent with MagSteps = {visuals.MagSteps}, but {rsi.Path} doesn't have state {state}!"); - } + Assert.That(sprite.TryGetLayer(id, out var layer)); + var rsi = layer.ActualRsi; + for (var i = start; i < visuals.MagSteps; i++) + { + var state = $"{visuals.MagState}{midfix}-{i}"; + Assert.That(rsi.TryGetState(state, out _), + @$"{proto.ID} has MagazineVisualsComponent with MagSteps = {visuals.MagSteps}, but {rsi.Path} doesn't have state {state}!"); + } - // MagSteps includes the 0th step, so sometimes people are off by one. - var extraState = $"{visuals.MagState}{midfix}-{visuals.MagSteps}"; - Assert.That(rsi.TryGetState(extraState, out _), Is.False, - @$"{proto.ID} has MagazineVisualsComponent with MagSteps = {visuals.MagSteps}, but more states exist!"); + // MagSteps includes the 0th step, so sometimes people are off by one. + var extraState = $"{visuals.MagState}{midfix}-{visuals.MagSteps}"; + Assert.That(rsi.TryGetState(extraState, out _), Is.False, + @$"{proto.ID} has MagazineVisualsComponent with MagSteps = {visuals.MagSteps}, but more states exist!"); + } } - } + }); }); await pair.CleanReturnAsync();