Esempio n. 1
0
        public void ValidateAllComponentsRemoved()
        {
            _defaultEntity.AddComponentA();
            _defaultEntity.AddComponentB();
            _defaultEntity.RemoveAllComponents();

            Assert.IsFalse(_defaultEntity.HasComponentA());
            Assert.IsFalse(_defaultEntity.HasComponentB());
            Assert.IsEmpty(_defaultEntity.GetComponents());
            Assert.IsEmpty(_defaultEntity.GetComponentIndices());
        }
        public void CopiesOfAllComponentsAddedToTargetEntity()
        {
            _entity.AddComponentA();
            _entity.AddComponent(CID.ComponentB, _nameAge);

#pragma warning disable CS0618  // Type or member is obsolete
#pragma warning disable HAA0101 // Array allocation for params parameter
            _entity.CopyTo(_target);
#pragma warning restore HAA0101 // Array allocation for params parameter
#pragma warning restore CS0618  // Type or member is obsolete

            Assert.AreEqual(2, _target.GetComponents().Length);
            Assert.IsTrue(_target.HasComponentA());
            Assert.IsTrue(_target.HasComponentB());
            Assert.AreNotEqual(Component.A, _target.GetComponentA());
            Assert.AreNotEqual(_nameAge, _target.GetComponent(CID.ComponentB));

            var clonedComponent = (NameAgeComponent)_target.GetComponent(CID.ComponentB);

            Assert.AreEqual(_nameAge.name, clonedComponent.name);
            Assert.AreEqual(_nameAge.age, clonedComponent.age);
        }
Esempio n. 3
0
        public void OnlyAddsCopiesOfSpecifiedComponentsToTargetEntity()
        {
            _originalEntity.AddComponentA();
            _originalEntity.AddComponentB();
            _originalEntity.AddComponentC();
            _originalEntity.CopyTo(
                _targetEntity,
                false,
                MyTestComponentsLookup.ComponentB,
                MyTestComponentsLookup.ComponentC);

            Assert.AreEqual(2, _targetEntity.GetComponents().Length);
            Assert.IsTrue(_targetEntity.HasComponentB());
            Assert.IsTrue(_targetEntity.HasComponentC());
        }