more entity tests
parent
1375adf63d
commit
116f424262
|
@ -1,8 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
using FluentAssertions;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
using Encompass;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
@ -27,10 +25,9 @@ namespace Tests
|
|||
mockComponent.myInt = 3;
|
||||
mockComponent.myString = "hello";
|
||||
|
||||
entity.AddComponent<MockComponent>(mockComponent);
|
||||
entity.AddComponent(mockComponent);
|
||||
|
||||
var world = worldBuilder.Build();
|
||||
// world.Update();
|
||||
|
||||
Assert.IsTrue(entity.HasComponent<MockComponent>());
|
||||
Assert.That(entity.GetComponent<MockComponent>().Value, Is.EqualTo(mockComponent));
|
||||
|
@ -54,9 +51,9 @@ namespace Tests
|
|||
mockComponentC.myInt = 1;
|
||||
mockComponentC.myString = "howdy";
|
||||
|
||||
var componentAID = entity.AddComponent<MockComponent>(mockComponentA);
|
||||
var componentBID = entity.AddComponent<MockComponent>(mockComponentB);
|
||||
var componentCID = entity.AddComponent<MockComponent>(mockComponentC);
|
||||
var componentAID = entity.AddComponent(mockComponentA);
|
||||
var componentBID = entity.AddComponent(mockComponentB);
|
||||
var componentCID = entity.AddComponent(mockComponentC);
|
||||
|
||||
var world = worldBuilder.Build();
|
||||
|
||||
|
@ -120,5 +117,56 @@ namespace Tests
|
|||
|
||||
Assert.IsFalse(entity.HasComponent<MockComponent>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveComponent()
|
||||
{
|
||||
var worldBuilder = new WorldBuilder();
|
||||
var entity = worldBuilder.CreateEntity();
|
||||
|
||||
MockComponent mockComponent;
|
||||
mockComponent.myInt = 3;
|
||||
mockComponent.myString = "hello";
|
||||
|
||||
var componentID = entity.AddComponent(mockComponent);
|
||||
|
||||
var world = worldBuilder.Build();
|
||||
|
||||
entity.RemoveComponent(componentID);
|
||||
|
||||
world.Update(0.01f);
|
||||
|
||||
Assert.IsFalse(entity.HasComponent<MockComponent>());
|
||||
Assert.IsEmpty(entity.GetComponents<MockComponent>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReactivateComponent()
|
||||
{
|
||||
var worldBuilder = new WorldBuilder();
|
||||
var entity = worldBuilder.CreateEntity();
|
||||
|
||||
MockComponent mockComponent;
|
||||
mockComponent.myInt = 3;
|
||||
mockComponent.myString = "hello";
|
||||
|
||||
var componentID = entity.AddComponent(mockComponent);
|
||||
|
||||
var world = worldBuilder.Build();
|
||||
|
||||
entity.DeactivateComponent(componentID);
|
||||
|
||||
world.Update(0.01f);
|
||||
|
||||
Assert.IsFalse(entity.HasComponent<MockComponent>());
|
||||
Assert.IsEmpty(entity.GetComponents<MockComponent>());
|
||||
|
||||
entity.ActivateComponent(componentID);
|
||||
|
||||
world.Update(0.01f);
|
||||
|
||||
Assert.IsTrue(entity.HasComponent<MockComponent>());
|
||||
Assert.IsNotEmpty(entity.GetComponents<MockComponent>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue