62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
using NUnit.Framework;
|
|||
|
using Encompass;
|
|||
|
|
|||
|
namespace Tests
|
|||
|
{
|
|||
|
public class EntityRendererTest
|
|||
|
{
|
|||
|
struct AComponent : IComponent { }
|
|||
|
struct BComponent : IComponent { }
|
|||
|
struct CComponent : IComponent { }
|
|||
|
|
|||
|
struct TestDrawComponent : IDrawComponent
|
|||
|
{
|
|||
|
public int Layer { get; set; }
|
|||
|
}
|
|||
|
|
|||
|
[Renders(typeof(TestDrawComponent), typeof(AComponent), typeof(BComponent))]
|
|||
|
class TestRenderer : EntityRenderer
|
|||
|
{
|
|||
|
public override void Render(Entity entity) { }
|
|||
|
}
|
|||
|
|
|||
|
[Test]
|
|||
|
public void CheckAndTrackEntities()
|
|||
|
{
|
|||
|
var worldBuilder = new WorldBuilder();
|
|||
|
var renderer = worldBuilder.AddRenderer<TestRenderer>();
|
|||
|
|
|||
|
AComponent aComponent;
|
|||
|
BComponent bComponent;
|
|||
|
TestDrawComponent testDrawComponent = default(TestDrawComponent);
|
|||
|
|
|||
|
var entityToTrack = worldBuilder.CreateEntity();
|
|||
|
entityToTrack.AddComponent(aComponent);
|
|||
|
entityToTrack.AddComponent(bComponent);
|
|||
|
entityToTrack.AddComponent(testDrawComponent);
|
|||
|
|
|||
|
var entityNotToTrack = worldBuilder.CreateEntity();
|
|||
|
entityNotToTrack.AddComponent(aComponent);
|
|||
|
entityNotToTrack.AddComponent(testDrawComponent);
|
|||
|
|
|||
|
var entityWithoutDrawComponent = worldBuilder.CreateEntity();
|
|||
|
entityWithoutDrawComponent.AddComponent(aComponent);
|
|||
|
entityWithoutDrawComponent.AddComponent(bComponent);
|
|||
|
|
|||
|
var world = worldBuilder.Build();
|
|||
|
|
|||
|
world.Update(0.01f);
|
|||
|
|
|||
|
Console.WriteLine(renderer.IsTracking(entityNotToTrack.id));
|
|||
|
|
|||
|
Assert.IsTrue(renderer.IsTracking(entityToTrack.id));
|
|||
|
Assert.IsFalse(renderer.IsTracking(entityNotToTrack.id));
|
|||
|
Assert.IsFalse(renderer.IsTracking(entityWithoutDrawComponent.id));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|