コード例 #1
0
        public void CanAddAndRemove()
        {
            var sourceNode = new Node(Utils.Id("foo"));
            var simpleMap  = new SimpleMap <NodeID, NodeID>();

            simpleMap.Init(sourceNode, db);
            for (int i = 0; i < 100; i++)
            {
                simpleMap.Add(Utils.Id($"foo/{i}"), Utils.Id("bar"));
            }
            for (int i = 0; i < 100; i += 2)
            {
                simpleMap.Remove(Utils.Id($"foo/{i}"));
            }
            for (int i = 0; i < 100; i++)
            {
                if (i % 2 == 1)
                {
                    Assert.Contains(Utils.Id($"foo/{i}"), simpleMap);
                }
                else
                {
                    Assert.DoesNotContain(Utils.Id($"foo/{i}"), simpleMap);
                }
            }
        }
コード例 #2
0
        public void CantInitEmpty()
        {
            var sourceNode = new Node(Utils.Id("foo"));
            var simpleList = new SimpleMap <NodeID, NodeID>();

            simpleList.Init(sourceNode, db);
        }
コード例 #3
0
        public void CanAddAndClear()
        {
            var sourceNode = new Node(Utils.Id("foo"));
            var simpleMap  = new SimpleMap <NodeID, NodeID>();

            simpleMap.Init(sourceNode, db);
            for (int i = 0; i < 100; i++)
            {
                simpleMap.Add(Utils.Id($"foo/{i}"), Utils.Id("bar"));
            }
            simpleMap.Clear();
            Assert.Empty(simpleMap);
        }
コード例 #4
0
        public void CantInit()
        {
            var sourceNode = new Node
            {
                Id         = Utils.Id("simpleMap1"),
                Attributes = new Map
                {
                    Items = new List <KeyValue>()
                }
            };
            var simpleList = new SimpleMap <NodeID, NodeID>();

            simpleList.Init(sourceNode, db);
        }
コード例 #5
0
        public void CanAddAndIterate()
        {
            var sourceNode = new Node(Utils.Id("foo"));
            var simpleMap  = new SimpleMap <NodeID, NodeID>();

            simpleMap.Init(sourceNode, db);
            for (int i = 0; i < 100; i++)
            {
                simpleMap.Add(Utils.Id($"foo/{i}"), Utils.Id("bar"));
            }

            for (int i = 0; i < 100; i++)
            {
                simpleMap.Contains(new KeyValuePair <NodeID, NodeID>(Utils.Id($"foo/{i}"), Utils.Id("bar")));
                Assert.Contains(Utils.Id($"foo/{i}"), simpleMap.Keys);
            }
        }