예제 #1
0
        public void CanStoreAndRetrieveComponent()
        {
            var component = new MockComponent();

            _entity.Add(component);
            Assert.AreSame(_entity.Get(typeof(MockComponent)), component);
        }
예제 #2
0
 public void CanRemoveComponent()
 {
     var component = new MockComponent();
     _entity.Add(component);
     _entity.Remove(typeof(MockComponent));
     Assert.IsFalse(_entity.Has(typeof(MockComponent)));
 }
예제 #3
0
        public void AddReturnsReferenceToEntity()
        {
            var component = new MockComponent();
            var e         = _entity.Add(component);

            Assert.AreSame(_entity, e);
        }
예제 #4
0
 public void CanReplaceComponent()
 {
     var component1 = new MockComponent();
     _entity.Add(component1);
     var component2 = new MockComponent();
     _entity.Add(component2);
     Assert.AreEqual(_entity.Get(typeof(MockComponent)), component2);
 }
예제 #5
0
        public void CanRemoveComponent()
        {
            var component = new MockComponent();

            _entity.Add(component);
            _entity.Remove(typeof(MockComponent));
            Assert.IsFalse(_entity.Has(typeof(MockComponent)));
        }
예제 #6
0
        public void ComponentAddedSignalContainsCorrectType()
        {
            Type type      = null;
            var  component = new MockComponent();

            _entity.ComponentAdded += (entity, componentType) => type = componentType;
            _entity.Add(component);
            Assert.AreEqual(typeof(MockComponent), type);
        }
예제 #7
0
 public void CanStoreAndRetrieveMultipleComponents()
 {
     var component1 = new MockComponent();
     _entity.Add(component1);
     var component2 = new MockComponent2();
     _entity.Add(component2);
     Assert.AreSame(_entity.Get(typeof(MockComponent)), component1);
     Assert.AreSame(_entity.Get(typeof(MockComponent2)), component2);
 }
예제 #8
0
 public void CanStoreBaseAndExtendedComponents()
 {
     var component1 = new MockComponent();
     _entity.Add(component1);
     var component2 = new MockComponentExtended();
     _entity.Add(component2);
     Assert.AreEqual(_entity.Get(typeof(MockComponent)), component1);
     Assert.AreEqual(_entity.Get(typeof(MockComponentExtended)), component2);
 }
예제 #9
0
        public void StoringComponentTriggersAddedSignal()
        {
            var eventFired = false;
            var component  = new MockComponent();

            _entity.ComponentAdded += (entity, componentType) => eventFired = true;
            _entity.Add(component);
            Assert.IsTrue(eventFired);
        }
예제 #10
0
        public void RemovingComponentTriggersRemovedSignal()
        {
            var eventFired = false;
            var component  = new MockComponent();

            _entity.Add(component);
            _entity.ComponentRemoved += (entity, componentType) => eventFired = true;
            _entity.Remove(typeof(MockComponent));
            Assert.IsTrue(eventFired);
        }
예제 #11
0
        public void CanReplaceComponent()
        {
            var component1 = new MockComponent();

            _entity.Add(component1);
            var component2 = new MockComponent();

            _entity.Add(component2);
            Assert.AreEqual(_entity.Get(typeof(MockComponent)), component2);
        }
예제 #12
0
        public void CanStoreBaseAndExtendedComponents()
        {
            var component1 = new MockComponent();

            _entity.Add(component1);
            var component2 = new MockComponentExtended();

            _entity.Add(component2);
            Assert.AreEqual(_entity.Get(typeof(MockComponent)), component1);
            Assert.AreEqual(_entity.Get(typeof(MockComponentExtended)), component2);
        }
예제 #13
0
        public void CanStoreAndRetrieveMultipleComponents()
        {
            var component1 = new MockComponent();

            _entity.Add(component1);
            var component2 = new MockComponent2();

            _entity.Add(component2);
            Assert.AreSame(_entity.Get(typeof(MockComponent)), component1);
            Assert.AreSame(_entity.Get(typeof(MockComponent2)), component2);
        }
예제 #14
0
        public void CloneChildComponentHasSameProperties()
        {
            var component = new MockComponent {
                Value = 5
            };

            _entity.Add(component);
            var clone = _entity.Clone();

            Assert.AreEqual(5, clone.Get <MockComponent>(typeof(MockComponent)).Value);
        }
예제 #15
0
        public void ComponentRemovedSignalContainsEntityWithRemovedComponent()
        {
            var component = new MockComponent {
                Value = 10
            };

            _entity.ComponentRemoved +=
                (entity, componentType) => component = (MockComponent)entity.Get(componentType);
            _entity.Add(component);
            _entity.Remove(typeof(MockComponent));
            Assert.IsNull(component);
        }
예제 #16
0
        public void ComponentAddedSignalEnablesAccessToComponentValue()
        {
            var value     = 0;
            var component = new MockComponent {
                Value = 10
            };

            _entity.ComponentAdded +=
                (entity, componentType) => value = ((MockComponent)entity.Get(componentType)).Value;
            _entity.Add(component);
            Assert.AreEqual(10, value);
        }
예제 #17
0
        public void WillRetrieveAllComponents()
        {
            var component1 = new MockComponent();

            _entity.Add(component1);
            var component2 = new MockComponent2();

            _entity.Add(component2);
            var all = _entity.GetAll();

            Assert.AreEqual(new List <object> {
                component1, component2
            }, all);
        }
예제 #18
0
 public void CanStoreAndRetrieveComponent()
 {
     var component = new MockComponent();
     _entity.Add(component);
     Assert.AreSame(_entity.Get(typeof(MockComponent)), component);
 }
예제 #19
0
 public void ComponentRemovedSignalContainsEntityWithRemovedComponent()
 {
     var component = new MockComponent { Value = 10 };
     _entity.ComponentRemoved +=
         (entity, componentType) => component = (MockComponent)entity.Get(componentType);
     _entity.Add(component);
     _entity.Remove(typeof(MockComponent));
     Assert.IsNull(component);
 }
예제 #20
0
 public void ComponentRemovedSignalContainsCorrectType()
 {
     Type type = null;
     var component = new MockComponent();
     _entity.ComponentRemoved += (entity, componentType) => type = componentType;
     _entity.Add(component);
     _entity.Remove(typeof(MockComponent));
     Assert.AreEqual(typeof(MockComponent), type);
 }
예제 #21
0
 public void RemovingComponentTriggersRemovedSignal()
 {
     var eventFired = false;
     var component = new MockComponent();
     _entity.Add(component);
     _entity.ComponentRemoved += (entity, componentType) => eventFired = true;
     _entity.Remove(typeof(MockComponent));
     Assert.IsTrue(eventFired);
 }
예제 #22
0
 public void WillRetrieveAllComponents()
 {
     var component1 = new MockComponent();
     _entity.Add(component1);
     var component2 = new MockComponent2();
     _entity.Add(component2);
     var all = _entity.GetAll();
     Assert.AreEqual(new List<object> { component1, component2 }, all);
 }
예제 #23
0
 public void AddReturnsReferenceToEntity()
 {
     var component = new MockComponent();
     var e = _entity.Add(component);
     Assert.AreSame(_entity, e);
 }
예제 #24
0
 public void StoringComponentTriggersAddedSignal()
 {
     var eventFired = false;
     var component = new MockComponent();
     _entity.ComponentAdded += (entity, componentType) => eventFired = true;
     _entity.Add(component);
     Assert.IsTrue(eventFired);
 }
예제 #25
0
 public void CloneChildComponentHasSameProperties()
 {
     var component = new MockComponent { Value = 5 };
     _entity.Add(component);
     var clone = _entity.Clone();
     Assert.AreEqual(5, clone.Get<MockComponent>(typeof(MockComponent)).Value);
 }
예제 #26
0
 public void ComponentAddedSignalEnablesAccessToComponentValue()
 {
     var value = 0;
     var component = new MockComponent { Value = 10 };
     _entity.ComponentAdded +=
         (entity, componentType) => value = ((MockComponent)entity.Get(componentType)).Value;
     _entity.Add(component);
     Assert.AreEqual(10, value);
 }