Adds temperature to solutions (#5834)
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Content.Tests.Shared.Chemistry
|
||||
{
|
||||
[TestFixture, Parallelizable, TestOf(typeof(Solution))]
|
||||
public class Solution_Tests
|
||||
public class Solution_Tests : ContentUnitTest
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
IoCManager.Resolve<IPrototypeManager>().Initialize();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddReagentAndGetSolution()
|
||||
{
|
||||
@@ -343,5 +351,134 @@ namespace Content.Tests.Shared.Chemistry
|
||||
Assert.That(solutionOne.GetReagentQuantity("earth").Int(), Is.EqualTo(1000));
|
||||
Assert.That(solutionOne.TotalVolume.Int(), Is.EqualTo(4500));
|
||||
}
|
||||
|
||||
// Tests concerning thermal energy and temperature.
|
||||
#region Thermal Energy and Temperature
|
||||
|
||||
[Test]
|
||||
public void EmptySolutionHasNoHeatCapacity()
|
||||
{
|
||||
var solution = new Solution();
|
||||
Assert.That(solution.HeatCapacity, Is.EqualTo(0.0f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptySolutionHasNoThermalEnergy()
|
||||
{
|
||||
var solution = new Solution();
|
||||
Assert.That(solution.ThermalEnergy, Is.EqualTo(0.0f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddReagentToEmptySolutionSetsTemperature()
|
||||
{
|
||||
const float testTemp = 100.0f;
|
||||
|
||||
var solution = new Solution();
|
||||
solution.AddReagent("water", FixedPoint2.New(100), testTemp);
|
||||
Assert.That(solution.Temperature, Is.EqualTo(testTemp));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddReagentWithNullTemperatureDoesNotEffectTemperature()
|
||||
{
|
||||
const float initialTemp = 100.0f;
|
||||
|
||||
var solution = new Solution();
|
||||
solution.AddReagent("water", FixedPoint2.New(100), initialTemp);
|
||||
|
||||
solution.AddReagent("water", FixedPoint2.New(100));
|
||||
Assert.That(solution.Temperature, Is.EqualTo(initialTemp));
|
||||
|
||||
solution.AddReagent("earth", FixedPoint2.New(100));
|
||||
Assert.That(solution.Temperature, Is.EqualTo(initialTemp));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddSolutionWithEqualTemperatureDoesNotChangeTemperature()
|
||||
{
|
||||
const float initialTemp = 100.0f;
|
||||
|
||||
var solutionOne = new Solution();
|
||||
solutionOne.AddReagent("water", FixedPoint2.New(100));
|
||||
solutionOne.Temperature = initialTemp;
|
||||
|
||||
var solutionTwo = new Solution();
|
||||
solutionTwo.AddReagent("water", FixedPoint2.New(100));
|
||||
solutionTwo.AddReagent("earth", FixedPoint2.New(100));
|
||||
solutionTwo.Temperature = initialTemp;
|
||||
|
||||
solutionOne.AddSolution(solutionTwo);
|
||||
Assert.That(solutionOne.Temperature, Is.EqualTo(initialTemp));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveReagentDoesNotEffectTemperature()
|
||||
{
|
||||
const float initialTemp = 100.0f;
|
||||
|
||||
var solution = new Solution();
|
||||
solution.AddReagent("water", FixedPoint2.New(100), initialTemp);
|
||||
solution.RemoveReagent("water", FixedPoint2.New(50));
|
||||
Assert.That(solution.Temperature, Is.EqualTo(initialTemp));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveSolutionDoesNotEffectTemperature()
|
||||
{
|
||||
const float initialTemp = 100.0f;
|
||||
|
||||
var solution = new Solution();
|
||||
solution.AddReagent("water", FixedPoint2.New(100), initialTemp);
|
||||
solution.RemoveSolution(FixedPoint2.New(50));
|
||||
Assert.That(solution.Temperature, Is.EqualTo(initialTemp));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SplitSolutionDoesNotEffectTemperature()
|
||||
{
|
||||
const float initialTemp = 100.0f;
|
||||
|
||||
var solution = new Solution();
|
||||
solution.AddReagent("water", FixedPoint2.New(100), initialTemp);
|
||||
solution.SplitSolution(FixedPoint2.New(50));
|
||||
Assert.That(solution.Temperature, Is.EqualTo(initialTemp));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddReagentWithSetTemperatureAdjustsTemperature()
|
||||
{
|
||||
const float temp = 100.0f;
|
||||
|
||||
var solution = new Solution();
|
||||
solution.AddReagent("water", FixedPoint2.New(100), temp * 1);
|
||||
Assert.That(solution.Temperature, Is.EqualTo(temp * 1));
|
||||
|
||||
solution.AddReagent("water", FixedPoint2.New(100), temp * 3);
|
||||
Assert.That(solution.Temperature, Is.EqualTo(temp * 2));
|
||||
|
||||
solution.AddReagent("earth", FixedPoint2.New(100), temp * 5);
|
||||
Assert.That(solution.Temperature, Is.EqualTo(temp * 3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddSolutionCombinesThermalEnergy()
|
||||
{
|
||||
const float initialTemp = 100.0f;
|
||||
|
||||
var solutionOne = new Solution();
|
||||
solutionOne.AddReagent("water", FixedPoint2.New(100), initialTemp);
|
||||
|
||||
var solutionTwo = new Solution();
|
||||
solutionTwo.AddReagent("water", FixedPoint2.New(100), initialTemp);
|
||||
solutionTwo.AddReagent("earth", FixedPoint2.New(100));
|
||||
|
||||
var thermalEnergyOne = solutionOne.ThermalEnergy;
|
||||
var thermalEnergyTwo = solutionTwo.ThermalEnergy;
|
||||
solutionOne.AddSolution(solutionTwo);
|
||||
Assert.That(solutionOne.ThermalEnergy, Is.EqualTo(thermalEnergyOne + thermalEnergyTwo));
|
||||
}
|
||||
|
||||
#endregion Thermal Energy and Temperature
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user