Files
space-station-14/Content.IntegrationTests/Tests/Atmos/GasMixtureTest.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

108 lines
3.5 KiB
C#

using Content.IntegrationTests.Fixtures;
using Content.Server.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Atmos
{
[TestFixture]
[TestOf(typeof(GasMixture))]
public sealed class GasMixtureTest : GameTest
{
[Test]
public async Task TestMerge()
{
var pair = Pair;
var server = pair.Server;
var atmosphereSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<AtmosphereSystem>();
await server.WaitAssertion(() =>
{
var a = new GasMixture(10f);
var b = new GasMixture(10f);
a.AdjustMoles(Gas.Oxygen, 50);
b.AdjustMoles(Gas.Nitrogen, 50);
// a now has 50 moles of oxygen
Assert.Multiple(() =>
{
Assert.That(a.TotalMoles, Is.EqualTo(50));
Assert.That(a.GetMoles(Gas.Oxygen), Is.EqualTo(50));
});
// b now has 50 moles of nitrogen
Assert.Multiple(() =>
{
Assert.That(b.TotalMoles, Is.EqualTo(50));
Assert.That(b.GetMoles(Gas.Nitrogen), Is.EqualTo(50));
});
atmosphereSystem.Merge(b, a);
// b now has its contents and the contents of a
Assert.Multiple(() =>
{
Assert.That(b.TotalMoles, Is.EqualTo(100));
Assert.That(b.GetMoles(Gas.Oxygen), Is.EqualTo(50));
Assert.That(b.GetMoles(Gas.Nitrogen), Is.EqualTo(50));
});
// a should be the same, however.
Assert.Multiple(() =>
{
Assert.That(a.TotalMoles, Is.EqualTo(50));
Assert.That(a.GetMoles(Gas.Oxygen), Is.EqualTo(50));
});
});
}
[Test]
[TestCase(0.5f)]
[TestCase(0.25f)]
[TestCase(0.75f)]
[TestCase(1f)]
[TestCase(0f)]
[TestCase(Atmospherics.BreathPercentage)]
public async Task RemoveRatio(float ratio)
{
var pair = Pair;
var server = pair.Server;
await server.WaitAssertion(() =>
{
var a = new GasMixture(10f);
a.AdjustMoles(Gas.Oxygen, 100);
a.AdjustMoles(Gas.Nitrogen, 100);
var origTotal = a.TotalMoles;
// we remove moles from the mixture with a ratio.
var b = a.RemoveRatio(ratio);
// check that the amount of moles in the original and the new mixture are correct.
Assert.Multiple(() =>
{
Assert.That(b.TotalMoles, Is.EqualTo(origTotal * ratio));
Assert.That(a.TotalMoles, Is.EqualTo(origTotal - b.TotalMoles));
});
Assert.Multiple(() =>
{
Assert.That(b.GetMoles(Gas.Oxygen), Is.EqualTo(100 * ratio));
Assert.That(b.GetMoles(Gas.Nitrogen), Is.EqualTo(100 * ratio));
});
Assert.Multiple(() =>
{
Assert.That(a.GetMoles(Gas.Oxygen), Is.EqualTo(100 - b.GetMoles(Gas.Oxygen)));
Assert.That(a.GetMoles(Gas.Nitrogen), Is.EqualTo(100 - b.GetMoles(Gas.Nitrogen)));
});
});
}
}
}