48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
|
using NUnit.Framework;
|
||
|
using System.Linq;
|
||
|
|
||
|
using Encompass;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Tests {
|
||
|
public class EngineTest
|
||
|
{
|
||
|
static IEnumerable<MockComponent> components;
|
||
|
|
||
|
public class TestEngine : Engine
|
||
|
{
|
||
|
public override void Update(float dt)
|
||
|
{
|
||
|
components = this.ReadComponents<MockComponent>();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void ReadComponents()
|
||
|
{
|
||
|
var worldBuilder = new WorldBuilder();
|
||
|
worldBuilder.AddEngine<TestEngine>();
|
||
|
|
||
|
var entity = worldBuilder.CreateEntity();
|
||
|
|
||
|
MockComponent mockComponent;
|
||
|
mockComponent.myInt = 0;
|
||
|
mockComponent.myString = "hello";
|
||
|
|
||
|
MockComponent mockComponentB;
|
||
|
mockComponentB.myInt = 1;
|
||
|
mockComponentB.myString = "howdy";
|
||
|
|
||
|
entity.AddComponent(mockComponent);
|
||
|
entity.AddComponent(mockComponentB);
|
||
|
|
||
|
var world = worldBuilder.Build();
|
||
|
|
||
|
world.Update(0.01f);
|
||
|
|
||
|
Assert.Contains(mockComponent, components.ToList());
|
||
|
Assert.Contains(mockComponentB, components.ToList());
|
||
|
}
|
||
|
}
|
||
|
}
|