Refactored integration tests to not use content entity prototypes (#2571)

* Refactored integration tests to not use content prototypes

* oops

* Apply suggestions from code review

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
DamianX
2020-11-18 15:30:36 +01:00
committed by GitHub
parent 501156f84c
commit 87e74c4494
17 changed files with 425 additions and 70 deletions

View File

@@ -17,10 +17,23 @@ namespace Content.IntegrationTests.Tests.Body
[TestOf(typeof(BodyComponent))]
public class LegTest : ContentIntegrationTest
{
private const string PROTOTYPES = @"
- type: entity
name: HumanBodyAndAppearanceDummy
id: HumanBodyAndAppearanceDummy
components:
- type: Appearance
- type: Body
template: HumanoidTemplate
preset: HumanPreset
centerSlot: torso
";
[Test]
public async Task RemoveLegsFallTest()
{
var server = StartServerDummyTicker();
var options = new ServerContentIntegrationOption{ExtraPrototypes = PROTOTYPES};
var server = StartServerDummyTicker(options);
AppearanceComponent appearance = null;
@@ -32,7 +45,7 @@ namespace Content.IntegrationTests.Tests.Body
mapManager.CreateNewMapEntity(mapId);
var entityManager = IoCManager.Resolve<IEntityManager>();
var human = entityManager.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);
var human = entityManager.SpawnEntity("HumanBodyAndAppearanceDummy", MapCoordinates.Nullspace);
Assert.That(human.TryGetComponent(out IBody body));
Assert.That(human.TryGetComponent(out appearance));

View File

@@ -23,10 +23,37 @@ namespace Content.IntegrationTests.Tests.Body
[TestOf(typeof(LungBehavior))]
public class LungTest : ContentIntegrationTest
{
private const string PROTOTYPES = @"
- type: entity
name: HumanBodyAndBloodstreamDummy
id: HumanBodyAndBloodstreamDummy
components:
- type: Bloodstream
max_volume: 100
- type: Body
template: HumanoidTemplate
preset: HumanPreset
centerSlot: torso
- type: Metabolism
metabolismHeat: 5000
radiatedHeat: 400
implicitHeatRegulation: 5000
sweatHeatRegulation: 5000
shiveringHeatRegulation: 5000
normalBodyTemperature: 310.15
thermalRegulationTemperatureThreshold: 25
needsGases:
Oxygen: 0.00060763888
producesGases:
Oxygen: 0.00045572916
CarbonDioxide: 0.00015190972
";
[Test]
public async Task AirConsistencyTest()
{
var server = StartServerDummyTicker();
var options = new ServerContentIntegrationOption{ExtraPrototypes = PROTOTYPES};
var server = StartServerDummyTicker(options);
server.Assert(() =>
{
@@ -36,7 +63,7 @@ namespace Content.IntegrationTests.Tests.Body
var entityManager = IoCManager.Resolve<IEntityManager>();
var human = entityManager.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);
var human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", MapCoordinates.Nullspace);
Assert.That(human.TryGetComponent(out IBody body));
Assert.That(body.TryGetMechanismBehaviors(out List<LungBehavior> lungs));

View File

@@ -103,10 +103,22 @@ namespace Content.IntegrationTests.Tests.Body
}
}
private const string PROTOTYPES = @"
- type: entity
name: HumanBodyDummy
id: HumanBodyDummy
components:
- type: Body
template: HumanoidTemplate
preset: HumanPreset
centerSlot: torso
";
[Test]
public async Task EventsTest()
{
var server = StartServerDummyTicker();
var options = new ServerContentIntegrationOption {ExtraPrototypes = PROTOTYPES};
var server = StartServerDummyTicker(options);
await server.WaitAssertion(() =>
{
@@ -116,7 +128,7 @@ namespace Content.IntegrationTests.Tests.Body
mapManager.CreateNewMapEntity(mapId);
var entityManager = IoCManager.Resolve<IEntityManager>();
var human = entityManager.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);
var human = entityManager.SpawnEntity("HumanBodyDummy", MapCoordinates.Nullspace);
Assert.That(human.TryGetComponent(out IBody? body));
Assert.NotNull(body);