EntityTests AddAndRemoveComponent Method Delta Engine Documentation

Namespace: DeltaEngine.Tests.Entities
Assembly: DeltaEngine.Tests (in DeltaEngine.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public void AddAndRemoveComponent()
Examples

[Test]
public void AddAndRemoveComponent()
{
    Assert.AreEqual(1, entities.NumberOfEntities);
    var entity = new MockEntity().Add(new object());
    Assert.AreEqual(2, entities.NumberOfEntities);
    Assert.AreEqual(1, entity.NumberOfComponents);
    Assert.IsNotNull(entity.Get<object>());
    entity.Remove<object>();
    Assert.AreEqual(0, entity.NumberOfComponents);
    Assert.IsFalse(entity.Contains<object>());
    Assert.Throws<ArgumentNullException>(() => new MockEntity().Add<object>(null));
}
See Also