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,9 +1,7 @@
using System.Threading.Tasks;
using Content.Client.Chemistry.UI;
using Content.IntegrationTests.Tests.Interaction;
using Content.Shared.Chemistry;
using Content.Shared.Containers.ItemSlots;
using NUnit.Framework;
namespace Content.IntegrationTests.Tests.Chemistry;
@@ -20,7 +18,7 @@ public sealed class DispenserTest : InteractionTest
// Insert beaker
await Interact("Beaker");
Assert.IsNull(Hands.ActiveHandEntity);
Assert.That(Hands.ActiveHandEntity, Is.Null);
// Open BUI
await Interact();
@@ -30,18 +28,18 @@ public sealed class DispenserTest : InteractionTest
await SendBui(ReagentDispenserUiKey.Key, ev);
// Beaker is back in the player's hands
Assert.IsNotNull(Hands.ActiveHandEntity);
Assert.That(Hands.ActiveHandEntity, Is.Not.Null);
AssertPrototype("Beaker", Hands.ActiveHandEntity);
// Re-insert the beaker
await Interact();
Assert.IsNull(Hands.ActiveHandEntity);
Assert.That(Hands.ActiveHandEntity, Is.Null);
// Re-eject using the button directly instead of sending a BUI event. This test is really just a test of the
// bui/window helper methods.
await ClickControl<ReagentDispenserWindow>(nameof(ReagentDispenserWindow.EjectButton));
await RunTicks(5);
Assert.IsNotNull(Hands.ActiveHandEntity);
Assert.That(Hands.ActiveHandEntity, Is.Not.Null);
AssertPrototype("Beaker", Hands.ActiveHandEntity);
}
}

View File

@@ -1,6 +1,5 @@
using System.Reflection;
using Content.Shared.FixedPoint;
using NUnit.Framework;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Value;
@@ -35,8 +34,10 @@ namespace Content.IntegrationTests.Tests.Chemistry
public void SerializeNullableValueTest()
{
var node = Serialization.WriteValue<FixedPoint2?>(FixedPoint2.New(2.5f));
#pragma warning disable NUnit2045 // Interdependent assertions
Assert.That(node is ValueDataNode);
Assert.That(((ValueDataNode)node).Value, Is.EqualTo("2.5"));
Assert.That(((ValueDataNode) node).Value, Is.EqualTo("2.5"));
#pragma warning restore NUnit2045
}
[Test]

View File

@@ -1,8 +1,6 @@
using System.Threading.Tasks;
using Content.Server.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
@@ -47,7 +45,11 @@ public sealed class SolutionSystemTests
[Test]
public async Task TryAddTwoNonReactiveReagent()
{
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>();
@@ -76,8 +78,11 @@ public sealed class SolutionSystemTests
solution.TryGetReagent("Water", out var water);
solution.TryGetReagent("Oil", out var oil);
Assert.That(water, Is.EqualTo(waterQuantity));
Assert.That(oil, Is.EqualTo(oilQuantity));
Assert.Multiple(() =>
{
Assert.That(water, Is.EqualTo(waterQuantity));
Assert.That(oil, Is.EqualTo(oilQuantity));
});
});
await pairTracker.CleanReturnAsync();
@@ -88,7 +93,11 @@ public sealed class SolutionSystemTests
[Test]
public async Task TryAddTooMuchNonReactiveReagent()
{
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 testMap = await PoolManager.CreateTestMap(pairTracker);
@@ -118,8 +127,11 @@ public sealed class SolutionSystemTests
solution.TryGetReagent("Water", out var water);
solution.TryGetReagent("Oil", out var oil);
Assert.That(water, Is.EqualTo(waterQuantity));
Assert.That(oil, Is.EqualTo(FixedPoint2.Zero));
Assert.Multiple(() =>
{
Assert.That(water, Is.EqualTo(waterQuantity));
Assert.That(oil, Is.EqualTo(FixedPoint2.Zero));
});
});
await pairTracker.CleanReturnAsync();
@@ -129,7 +141,11 @@ public sealed class SolutionSystemTests
[Test]
public async Task TryMixAndOverflowTooMuchReagent()
{
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;
@@ -141,10 +157,10 @@ public sealed class SolutionSystemTests
EntityUid beaker;
await server.WaitAssertion((System.Action)(() =>
await server.WaitAssertion(() =>
{
int ratio = 9;
int threshold = 20;
var ratio = 9;
var threshold = 20;
var waterQuantity = FixedPoint2.New(10);
var oilQuantity = FixedPoint2.New(ratio * waterQuantity.Int());
@@ -159,18 +175,23 @@ public sealed class SolutionSystemTests
Assert.That(containerSystem
.TryMixAndOverflow(beaker, solution, oilAdded, threshold, out var overflowingSolution));
Assert.That(solution.Volume, Is.EqualTo(FixedPoint2.New(threshold)));
solution.TryGetReagent("Water", out var waterMix);
solution.TryGetReagent("Oil", out var oilMix);
Assert.That(waterMix, Is.EqualTo(FixedPoint2.New(threshold / (ratio + 1))));
Assert.That(oilMix, Is.EqualTo(FixedPoint2.New(threshold / (ratio + 1) * ratio)));
Assert.Multiple(() =>
{
Assert.That(solution.Volume, Is.EqualTo(FixedPoint2.New(threshold)));
Assert.That(overflowingSolution.Volume, Is.EqualTo(FixedPoint2.New(80)));
overflowingSolution.TryGetReagent("Water", out var waterOverflow);
overflowingSolution.TryGetReagent("Oil", out var oilOverFlow);
Assert.That(waterOverflow, Is.EqualTo(waterQuantity - waterMix));
Assert.That(oilOverFlow, Is.EqualTo(oilQuantity - oilMix));
}));
solution.TryGetReagent("Water", out var waterMix);
solution.TryGetReagent("Oil", out var oilMix);
Assert.That(waterMix, Is.EqualTo(FixedPoint2.New(threshold / (ratio + 1))));
Assert.That(oilMix, Is.EqualTo(FixedPoint2.New(threshold / (ratio + 1) * ratio)));
Assert.That(overflowingSolution.Volume, Is.EqualTo(FixedPoint2.New(80)));
overflowingSolution.TryGetReagent("Water", out var waterOverflow);
overflowingSolution.TryGetReagent("Oil", out var oilOverFlow);
Assert.That(waterOverflow, Is.EqualTo(waterQuantity - waterMix));
Assert.That(oilOverFlow, Is.EqualTo(oilQuantity - oilMix));
});
});
await pairTracker.CleanReturnAsync();
}
@@ -179,7 +200,11 @@ public sealed class SolutionSystemTests
[Test]
public async Task TryMixAndOverflowTooBigOverflow()
{
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>();
@@ -192,8 +217,8 @@ public sealed class SolutionSystemTests
await server.WaitAssertion(() =>
{
int ratio = 9;
int threshold = 60;
var ratio = 9;
var threshold = 60;
var waterQuantity = FixedPoint2.New(10);
var oilQuantity = FixedPoint2.New(ratio * waterQuantity.Int());

View File

@@ -1,11 +1,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Engineering.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
@@ -29,7 +25,11 @@ namespace Content.IntegrationTests.Tests.Chemistry
[Test]
public async Task TryAllTest()
{
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>();
@@ -54,9 +54,11 @@ namespace Content.IntegrationTests.Tests.Chemistry
.TryGetSolution(beaker, "beaker", out component));
foreach (var (id, reactant) in reactionPrototype.Reactants)
{
#pragma warning disable NUnit2045
Assert.That(solutionSystem
.TryAddReagent(beaker, component, id, reactant.Amount, out var quantity));
Assert.That(reactant.Amount, Is.EqualTo(quantity));
#pragma warning restore NUnit2045
}
solutionSystem.SetTemperature(beaker, component, reactionPrototype.MinimumTemperature);