Exemple #1
0
        public static void InsertTest()
        {
            var valueList = new ValueList <int>(new int[] { 1, 2, 3 });

            valueList.Insert(3, 4);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(6)
                        .And.Count.EqualTo(4)
                        );

            Assert.That(() => valueList[3],
                        Is.EqualTo(4)
                        );

            Assert.That(() => valueList.Insert(5, 5),
                        Throws.InstanceOf <ArgumentOutOfRangeException>()
                        .And.Property("ActualValue").EqualTo(5)
                        .And.Property("ParamName").EqualTo("index")
                        );

            valueList = new ValueList <int>();
            valueList.Insert(0, 1);

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(1)
                        .And.Count.EqualTo(1)
                        );

            Assert.That(() => valueList[0],
                        Is.EqualTo(1)
                        );
        }
        public void ValueListTest()
        {
            var list = new ValueList <int>();

            for (int i = 0; i < 10; i++)
            {
                list.AddRange(new[] { 0, 1, 2, 3 });
                list.Add(4);
                list.Insert(list.Count, 5);
            }

            list.Insert(0, -1);
            list.Insert(1, 1);
        }
        public virtual void MoveValue(int newIndex, int currentIndex)
        {
            var value = ValueList[currentIndex];
            var pair  = PairList[currentIndex];

            ValueList.RemoveAt(currentIndex);
            PairList.RemoveAt(currentIndex);
            ValueList.Insert(newIndex, value);
            PairList.Insert(newIndex, pair);
        }
        public virtual bool Insert(int index, string key, T value)
        {
            if (!base.AddKeyedValue(key, value))
            {
                return(false);
            }

            PairList.Insert(index, new KeyValuePair <string, T>(key, value));
            ValueList.Insert(index, value);
            return(true);
        }
        public void Enumerate()
        {
            var test = new ValueList<ValueInt>(() => ValueInt.GetValues(5));
            test.Insert(0, 4, 0);

            int index = 0;
            int[] indexes = { 4, 0, 0 };
            foreach (var item in test.List)
            {
                Assert.AreEqual<ValueInt>(test.Values[indexes[index++]], item);
            }
        }
Exemple #6
0
        public Bucket Prepend(Bucket bucket)
        {
            if (bucket is null || bucket is EmptyBucket)
            {
                return(this);
            }

            if (_keepOpen)
            {
                return(new SimpleAggregate(bucket, this));
            }
            else
            {
                lock (LockOn)
                {
                    _buckets.Insert(0, bucket);
                }
            }
            return(this);
        }
 public void Remove()
 {
     var test = new ValueList<ValueInt>(() => ValueInt.GetValues(5));
     test.Insert(0, 4, 0);
     test.Remove(4, 0, 0);
 }
 public void Insert()
 {
     var test = new ValueList<ValueInt>(() => ValueInt.GetValues(5));
     test.Insert(0, 4, 0);
     test.Verify(4, 0, 0);
 }
Exemple #9
0
 public void InitVaribleList()
 {
     ValueList = WorkflowManager.Instance.Context.WorkFlow.Variables.Items.Select(x => x.Name).ToList();
     ValueList.Insert(0, "");
 }