Files
space-station-14/Content.IntegrationTests/Tests/Chemistry/SolutionRoundingTest.cs
T
Moony d42adbf05d Gametest Part 2: Preliminary refactor every test to use GameTest as the framework. (#43207)
* Pass 1.

* i'm FREE

* Prevent hangups.

* okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing.

* sigh.

* fix singular trigger bug so LatheTest doesn't flake.

* Remove SystemAttribute usage.

* Poke

* I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls.

* Change the faulty store test into two tests, one of which is ignored for failing.
2026-04-01 16:06:26 +00:00

127 lines
4.0 KiB
C#

using Content.IntegrationTests.Fixtures;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Chemistry;
[TestFixture]
[TestOf(typeof(ChemicalReactionSystem))]
public sealed class SolutionRoundingTest : GameTest
{
// This test tests two things:
// * A rounding error in reaction code while I was making chloral hydrate
// * An assert with solution heat capacity calculations that I found a repro for while testing the above.
[TestPrototypes]
private const string Prototypes = @"
- type: entity
id: SolutionRoundingTestContainer
components:
- type: SolutionContainerManager
solutions:
beaker:
maxVol: 100
# This is the Chloral Hydrate recipe fyi.
- type: reagent
id: SolutionRoundingTestReagentA
name: reagent-name-nothing
desc: reagent-desc-nothing
physicalDesc: reagent-physical-desc-nothing
- type: reagent
id: SolutionRoundingTestReagentB
name: reagent-name-nothing
desc: reagent-desc-nothing
physicalDesc: reagent-physical-desc-nothing
- type: reagent
id: SolutionRoundingTestReagentC
name: reagent-name-nothing
desc: reagent-desc-nothing
physicalDesc: reagent-physical-desc-nothing
- type: reagent
id: SolutionRoundingTestReagentD
name: reagent-name-nothing
desc: reagent-desc-nothing
physicalDesc: reagent-physical-desc-nothing
- type: reaction
id: SolutionRoundingTestReaction
impact: Medium
reactants:
SolutionRoundingTestReagentA:
amount: 3
SolutionRoundingTestReagentB:
amount: 1
SolutionRoundingTestReagentC:
amount: 1
products:
SolutionRoundingTestReagentD: 1
";
private const string SolutionRoundingTestReagentA = "SolutionRoundingTestReagentA";
private const string SolutionRoundingTestReagentB = "SolutionRoundingTestReagentB";
private const string SolutionRoundingTestReagentC = "SolutionRoundingTestReagentC";
private const string SolutionRoundingTestReagentD = "SolutionRoundingTestReagentD";
[Test]
public async Task Test()
{
var pair = Pair;
var server = pair.Server;
var testMap = await pair.CreateTestMap();
Solution solution = default;
Entity<SolutionComponent> solutionEnt = default;
await server.WaitPost(() =>
{
var system = server.System<SharedSolutionContainerSystem>();
var beaker = server.EntMan.SpawnEntity("SolutionRoundingTestContainer", testMap.GridCoords);
system.TryGetSolution(beaker, "beaker", out var newSolutionEnt, out var newSolution);
solutionEnt = newSolutionEnt!.Value;
solution = newSolution!;
system.TryAddSolution(solutionEnt, new Solution(SolutionRoundingTestReagentC, 50));
system.TryAddSolution(solutionEnt, new Solution(SolutionRoundingTestReagentB, 30));
for (var i = 0; i < 9; i++)
{
system.TryAddSolution(solutionEnt, new Solution(SolutionRoundingTestReagentA, 10));
}
});
await server.WaitAssertion(() =>
{
Assert.Multiple(() =>
{
Assert.That(
solution.ContainsReagent(SolutionRoundingTestReagentA, null),
Is.False,
"Solution should not contain reagent A");
Assert.That(
solution.ContainsReagent(SolutionRoundingTestReagentB, null),
Is.False,
"Solution should not contain reagent B");
Assert.That(
solution![new ReagentId(SolutionRoundingTestReagentC, null)].Quantity,
Is.EqualTo((FixedPoint2) 20));
Assert.That(
solution![new ReagentId(SolutionRoundingTestReagentD, null)].Quantity,
Is.EqualTo((FixedPoint2) 30));
});
});
}
}