Fix content.integration tests warnings (#17817)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
TemporalOroboros
2023-07-05 21:54:25 -07:00
committed by GitHub
parent 20c1754abd
commit ba91023a85
121 changed files with 3658 additions and 1961 deletions

View File

@@ -1,10 +1,8 @@
using System.Linq;
using System.Threading.Tasks;
using Content.IntegrationTests.Tests.Construction.Interaction;
using Content.IntegrationTests.Tests.Interaction;
using Content.IntegrationTests.Tests.Weldable;
using Content.Server.Tools.Components;
using NUnit.Framework;
namespace Content.IntegrationTests.Tests.DoAfter;
@@ -18,7 +16,7 @@ public sealed class DoAfterCancellationTests : InteractionTest
public async Task CancelWallDeconstruct()
{
await StartDeconstruction(WallConstruction.WallSolid);
await Interact(Weld, awaitDoAfters:false);
await Interact(Weld, awaitDoAfters: false);
// Failed do-after has no effect
await CancelDoAfters();
@@ -30,7 +28,7 @@ public sealed class DoAfterCancellationTests : InteractionTest
// Repeat for wrenching interaction
AssertAnchored();
await Interact(Wrench, awaitDoAfters:false);
await Interact(Wrench, awaitDoAfters: false);
await CancelDoAfters();
AssertAnchored();
AssertPrototype(WallConstruction.Girder);
@@ -39,7 +37,7 @@ public sealed class DoAfterCancellationTests : InteractionTest
// Repeat for screwdriver interaction.
AssertDeleted(false);
await Interact(Screw, awaitDoAfters:false);
await Interact(Screw, awaitDoAfters: false);
await CancelDoAfters();
AssertDeleted(false);
await Interact(Screw);
@@ -50,13 +48,13 @@ public sealed class DoAfterCancellationTests : InteractionTest
public async Task CancelWallConstruct()
{
await StartConstruction(WallConstruction.Wall);
await Interact(Steel, 5, awaitDoAfters:false);
await Interact(Steel, 5, awaitDoAfters: false);
await CancelDoAfters();
Assert.That(Target.HasValue && Target.Value.IsClientSide());
await Interact(Steel, 5);
AssertPrototype(WallConstruction.Girder);
await Interact(Steel, 5, awaitDoAfters:false);
await Interact(Steel, 5, awaitDoAfters: false);
await CancelDoAfters();
AssertPrototype(WallConstruction.Girder);
@@ -68,7 +66,7 @@ public sealed class DoAfterCancellationTests : InteractionTest
public async Task CancelTilePry()
{
await SetTile(Floor);
await Interact(Pry, awaitDoAfters:false);
await Interact(Pry, awaitDoAfters: false);
await CancelDoAfters();
await AssertTile(Floor);
@@ -80,7 +78,7 @@ public sealed class DoAfterCancellationTests : InteractionTest
public async Task CancelRepeatedTilePry()
{
await SetTile(Floor);
await Interact(Pry, awaitDoAfters:false);
await Interact(Pry, awaitDoAfters: false);
await RunTicks(1);
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(1));
await AssertTile(Floor);
@@ -102,35 +100,56 @@ public sealed class DoAfterCancellationTests : InteractionTest
await SpawnTarget(WeldableTests.Locker);
var comp = Comp<WeldableComponent>();
Assert.That(comp.Weldable, Is.True);
Assert.That(comp.IsWelded, Is.False);
Assert.Multiple(() =>
{
Assert.That(comp.Weldable, Is.True);
Assert.That(comp.IsWelded, Is.False);
});
await Interact(Weld, awaitDoAfters:false);
await Interact(Weld, awaitDoAfters: false);
await RunTicks(1);
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(1));
Assert.That(comp.IsWelded, Is.False);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(1));
Assert.That(comp.IsWelded, Is.False);
});
// Second DoAfter cancels the first.
// Not using helper, because it runs too many ticks & causes the do-after to finish.
await Server.WaitPost(() => InteractSys.UserInteraction(Player, TargetCoords, Target));
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.False);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.False);
});
// Third do after will work fine
await Interact(Weld);
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.True);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.True);
});
// Repeat test for un-welding
await Interact(Weld, awaitDoAfters:false);
await Interact(Weld, awaitDoAfters: false);
await RunTicks(1);
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(1));
Assert.That(comp.IsWelded, Is.True);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(1));
Assert.That(comp.IsWelded, Is.True);
});
await Server.WaitPost(() => InteractSys.UserInteraction(Player, TargetCoords, Target));
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.True);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.True);
});
await Interact(Weld);
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.False);
Assert.Multiple(() =>
{
Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0));
Assert.That(comp.IsWelded, Is.False);
});
}
}

View File

@@ -1,9 +1,5 @@
using System;
using System.Threading.Tasks;
using Content.Shared.DoAfter;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Reflection;
using Robust.Shared.Serialization;
@@ -35,7 +31,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
[Test]
public async Task TestSerializable()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server;
await server.WaitIdleAsync();
var refMan = server.ResolveDependency<IReflectionManager>();
@@ -62,7 +58,11 @@ namespace Content.IntegrationTests.Tests.DoAfter
[Test]
public async Task TestFinished()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{
NoClient = true,
ExtraPrototypes = Prototypes
});
var server = pairTracker.Pair.Server;
await server.WaitIdleAsync();
@@ -77,8 +77,10 @@ namespace Content.IntegrationTests.Tests.DoAfter
var tickTime = 1.0f / timing.TickRate;
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace);
var args = new DoAfterArgs(mob, tickTime / 2, ev, null) { Broadcast = true };
#pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(doAfterSystem.TryStartDoAfter(args));
Assert.That(ev.Cancelled, Is.False);
#pragma warning restore NUnit2045
});
await server.WaitRunTicks(1);
@@ -90,12 +92,15 @@ namespace Content.IntegrationTests.Tests.DoAfter
[Test]
public async Task TestCancelled()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{
NoClient = true,
ExtraPrototypes = Prototypes
});
var server = pairTracker.Pair.Server;
var entityManager = server.ResolveDependency<IEntityManager>();
var timing = server.ResolveDependency<IGameTiming>();
var doAfterSystem = entityManager.EntitySysManager.GetEntitySystem<SharedDoAfterSystem>();
DoAfterId? id;
var ev = new TestDoAfterEvent();
await server.WaitPost(() =>
@@ -105,7 +110,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace);
var args = new DoAfterArgs(mob, tickTime * 2, ev, null) { Broadcast = true };
if (!doAfterSystem.TryStartDoAfter(args, out id))
if (!doAfterSystem.TryStartDoAfter(args, out var id))
{
Assert.Fail();
return;