public void CleanUpEmptiesNodeList()
 {
     var entity = new EntityBase();
     entity.Add(new Vector2());
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     _family.CleanUp();
     Assert.IsNull(nodes.Head);
 }
Beispiel #2
0
 public void TestComponentAddedChecksWithAllFamilies()
 {
     _game.GetNodeList<MockNode>();
     _game.GetNodeList<MockNode2>();
     var entity = new EntityBase();
     _game.AddEntity(entity);
     entity.Add(new Vector2());
     var results = new List<int>
     {
         MockFamily.Instances[0].ComponentAddedCalls,
         MockFamily.Instances[1].ComponentAddedCalls
     };
     Assert.AreEqual(new List<int> { 1, 1 }, results);
 }
        public virtual SdataTransactionResult Add(FeedEntry payload)
        {
            Document document = GetTransformedDocument(payload);
            List <TransactionResult> transactionResults = new List <TransactionResult>();

            _entity.Add(document, _context.Config, ref transactionResults);

            SdataTransactionResult sdTrResult = GetSdataTransactionResult(transactionResults,
                                                                          _context.OriginEndPoint, _resourceKind);

            if (sdTrResult != null)
            {
                sdTrResult.HttpMethod = HttpMethod.POST;
            }
            return(sdTrResult);
        }
        public void CleanUpSetsNextNodeToNull()
        {
            var entities = new List<EntityBase>();
            for (var i = 0; i < 5; ++i)
            {
                var entity = new EntityBase();
                entity.Add(new Vector2());
                entities.Add(entity);
                _family.NewEntity(entity);
            }

            var nodes = _family.NodeList;
            var node = nodes.Head.Next;
            _family.CleanUp();
            Assert.IsNull(node.Next);
        }
Beispiel #5
0
        public virtual SdataTransactionResult Add(PayloadBase payload, List <SyncFeedEntryLink> links)
        {
            Document document = GetTransformedDocument(payload, links);
            List <TransactionResult> transactionResults = new List <TransactionResult>();

            _entity.Add(document, _context.Config, ref transactionResults);

            SdataTransactionResult sdTrResult = Helper.GetSdataTransactionResult(transactionResults,
                                                                                 _context.OriginEndPoint, _resourceKind);

            if (sdTrResult != null)
            {
                sdTrResult.HttpMessage = "POST";
            }
            return(sdTrResult);
        }
        public void NodeListContainsAllMatchingEntities()
        {
            var entities = new List<EntityBase>();
            for (var i = 0; i < 5; ++i)
            {
                var entity = new EntityBase();
                entity.Add(new Vector2());
                entities.Add(entity);
                _family.NewEntity(entity);
                _family.NewEntity(new EntityBase());
            }

            var nodes = _family.NodeList;
            for (var node = nodes.Head; node != null; node = node.Next)
            {
                entities.RemoveAt(entities.IndexOf(node.Entity));
            }
            Assert.AreEqual(0, entities.Count);
        }
        public void NodeListContainsOnlyMatchingEntities()
        {
            var entities = new List<EntityBase>();
            for (var i = 0; i < 5; ++i)
            {
                var entity = new EntityBase();
                entity.Add(new Vector2());
                entities.Add(entity);
                _family.NewEntity(entity);
                _family.NewEntity(new EntityBase());
            }

            var nodes = _family.NodeList;
            var results = new List<bool>();
            for (var node = nodes.Head; node != null; node = node.Next)
            {
                results.Add(entities.Contains(node.Entity));
            }

            Assert.AreEqual(new List<bool> { true, true, true, true, true }, results);
        }
 public void TestNonMatchingEntityIsNotAddedWhenComponentAdded()
 {
     var entity = new EntityBase();
     entity.Add(new Matrix4x4());
     _family.ComponentAddedToEntity(entity, typeof(Matrix4x4));
     var nodes = _family.NodeList;
     Assert.IsNull(nodes.Head);
 }
 public void TestNodeContainsEntityProperties()
 {
     var entity = new EntityBase();
     var point = new Vector2(1, 2);
     entity.Add(point);
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     Assert.AreEqual(point, ((MockNode)nodes.Head).Point);
 }
 public void TestMatchingEntityIsAddedWhenComponentAdded()
 {
     var nodes = _family.NodeList;
     var entity = new EntityBase();
     entity.Add(new Vector2());
     _family.ComponentAddedToEntity(entity, typeof(Vector2));
     Assert.AreSame(entity, nodes.Head.Entity);
 }
 public void TestMatchingEntityIsAddedWhenAccessNodeListSecond()
 {
     var entity = new EntityBase();
     entity.Add(new Vector2());
     _family.NewEntity(entity);
     var nodes = _family.NodeList;
     Assert.AreSame(entity, nodes.Head.Entity);
 }
 public void TestEntityIsRemovedWhenComponentRemoved()
 {
     var entity = new EntityBase();
     entity.Add(new Vector2());
     _family.NewEntity(entity);
     entity.Remove(typeof(Vector2));
     _family.ComponentRemovedFromEntity(entity, typeof(Vector2));
     var nodes = _family.NodeList;
     Assert.IsNull(nodes.Head);
 }
 public void TestEntityIsRemovedWhenAccessNodeListSecond()
 {
     var entity = new EntityBase();
     entity.Add(new Vector2());
     _family.NewEntity(entity);
     _family.RemoveEntity(entity);
     var nodes = _family.NodeList;
     Assert.IsNull(nodes.Head);
 }