Add test for non abstract entities without icons (#1666)

* Add test for non abstract entities without icons

Fixes #575.
Test will now fail if an entity is added that is not abstract but has no icon.
Also added icons or made entities abstract that failed the test.
No non abstract entities actually missed textures.

Some notes: Changed name of "constructionghost" from "spooky ghost" to "construction ghost", and changed name of "AdminObserver" from "observer" to "admin observer" to avoid overlap in names.

* Split up client side and server side tests
This commit is contained in:
Vince
2020-08-18 13:46:12 +02:00
committed by GitHub
parent bbc01c7e47
commit e076d93e1f
9 changed files with 69 additions and 30 deletions

View File

@@ -19,7 +19,7 @@ namespace Content.IntegrationTests.Tests
public class EntityTest : ContentIntegrationTest public class EntityTest : ContentIntegrationTest
{ {
[Test] [Test]
public async Task Test() public async Task SpawnTest()
{ {
var server = StartServerDummyTicker(); var server = StartServerDummyTicker();
await server.WaitIdleAsync(); await server.WaitIdleAsync();
@@ -41,43 +41,65 @@ namespace Content.IntegrationTests.Tests
}); });
server.Assert(() => server.Assert(() =>
{
var testLocation = new GridCoordinates(new Vector2(0, 0), grid);
//Generate list of non-abstract prototypes to test
foreach (var prototype in prototypeMan.EnumeratePrototypes<EntityPrototype>())
{ {
var testLocation = new GridCoordinates(new Vector2(0, 0), grid); if (prototype.Abstract)
//Generate list of non-abstract prototypes to test
foreach (var prototype in prototypeMan.EnumeratePrototypes<EntityPrototype>())
{ {
if (prototype.Abstract) continue;
{ }
continue; prototypes.Add(prototype);
} }
prototypes.Add(prototype);
//Iterate list of prototypes to spawn
foreach (var prototype in prototypes)
{
try
{
Logger.LogS(LogLevel.Debug, "EntityTest", "Testing: " + prototype.ID);
testEntity = entityMan.SpawnEntity(prototype.ID, testLocation);
server.RunTicks(2);
Assert.That(testEntity.Initialized);
entityMan.DeleteEntity(testEntity.Uid);
} }
//Iterate list of prototypes to spawn //Fail any exceptions thrown on spawn
foreach (var prototype in prototypes) catch (Exception e)
{ {
try Logger.LogS(LogLevel.Error, "EntityTest", "Entity '" + prototype.ID + "' threw: " + e.Message);
{ //Assert.Fail();
Logger.LogS(LogLevel.Debug, "EntityTest", "Testing: " + prototype.ID); throw;
testEntity = entityMan.SpawnEntity(prototype.ID, testLocation);
server.RunTicks(2);
Assert.That(testEntity.Initialized);
entityMan.DeleteEntity(testEntity.Uid);
}
//Fail any exceptions thrown on spawn
catch (Exception e)
{
Logger.LogS(LogLevel.Error, "EntityTest", "Entity '" + prototype.ID + "' threw: " + e.Message);
//Assert.Fail();
throw;
}
} }
}); }
});
await server.WaitIdleAsync(); await server.WaitIdleAsync();
} }
[Test]
public async Task NotAbstractIconTest()
{
var client = StartClient();
await client.WaitIdleAsync();
var prototypeMan = client.ResolveDependency<IPrototypeManager>();
client.Assert(() =>
{
foreach (var prototype in prototypeMan.EnumeratePrototypes<EntityPrototype>())
{
if (prototype.Abstract)
{
continue;
}
Assert.That(prototype.Components.ContainsKey("Icon"), $"Entity {prototype.ID} does not have an Icon component, but is not abstract");
}
});
await client.WaitIdleAsync();
}
} }
} }

View File

@@ -9,6 +9,8 @@
- type: Collidable - type: Collidable
- type: Sprite - type: Sprite
texture: Constructible/Misc/TurrBase.png texture: Constructible/Misc/TurrBase.png
- type: Icon
texture: Constructible/Misc/TurrBase.png
- type: entity - type: entity
id: TurretTopGun id: TurretTopGun
@@ -23,6 +25,8 @@
drawdepth: WallMountedItems drawdepth: WallMountedItems
texture: Constructible/Misc/TurrTop.png texture: Constructible/Misc/TurrTop.png
directional: false directional: false
- type: Icon
texture: Constructible/Misc/TurrTop.png
- type: entity - type: entity
id: TurretTopLight id: TurretTopLight
@@ -35,6 +39,8 @@
drawdepth: WallMountedItems drawdepth: WallMountedItems
texture: Constructible/Misc/TurrLamp.png texture: Constructible/Misc/TurrLamp.png
directional: false directional: false
- type: Icon
texture: Constructible/Misc/TurrLamp.png
- type: PointLight - type: PointLight
radius: 512 radius: 512
mask: flashlight_mask mask: flashlight_mask

View File

@@ -19,6 +19,7 @@
- type: entity - type: entity
id: DisposalHolder id: DisposalHolder
abstract: true
name: disposal holder name: disposal holder
components: components:
- type: DisposalHolder - type: DisposalHolder

View File

@@ -1,6 +1,7 @@
- type: entity - type: entity
name: spooky ghost name: construction ghost
id: constructionghost id: constructionghost
abstract: true
components: components:
- type: Sprite - type: Sprite
color: '#3F38' color: '#3F38'
@@ -12,6 +13,7 @@
- type: entity - type: entity
name: somebody-messed-up frame name: somebody-messed-up frame
id: structureconstructionframe id: structureconstructionframe
abstract: true
components: components:
- type: Sprite - type: Sprite
- type: Construction - type: Construction

View File

@@ -1,6 +1,7 @@
- type: entity - type: entity
name: drag shadow name: drag shadow
id: dragshadow id: dragshadow
abstract: true
components: components:
- type: Sprite - type: Sprite
layers: layers:

View File

@@ -1,6 +1,7 @@
- type: entity - type: entity
name: hover entity name: hover entity
id: hoverentity id: hoverentity
abstract: true
components: components:
- type: Sprite - type: Sprite
layers: layers:

View File

@@ -6,6 +6,9 @@
netsync: false netsync: false
sprite: Interface/Misc/pointing.rsi sprite: Interface/Misc/pointing.rsi
state: pointing state: pointing
- type: Icon
sprite: Interface/Misc/pointing.rsi
state: pointing
- type: PointingArrow - type: PointingArrow
duration: 4 duration: 4
step: 0.5 step: 0.5

View File

@@ -2,3 +2,5 @@
parent: MobObserver parent: MobObserver
save: false save: false
id: AdminObserver id: AdminObserver
name: admin observer
abstract: true

View File

@@ -1,6 +1,7 @@
- type: entity - type: entity
id: MobObserver id: MobObserver
name: observer name: observer
abstract: true
save: false save: false
description: Boo! description: Boo!
components: components: