Пример #1
0
        public void Append_Add_Item_To_End()
        {
            var source = new List <int> {
                0, 1, 2, 3, 4, 5, 6, 7
            };

            var result = EnumerableExtensions.Append(source, -1);

            var aResult = result.ToArray();

            Assert.Equal(-1, aResult[aResult.Length - 1]);
            Assert.Equal(7, aResult[aResult.Length - 2]);

            Assert.Equal(8, source.Count());
            Assert.Equal(9, aResult.Length);
        }
Пример #2
0
 public void Append()
 {
     tlog.Debug(tag, $"Append START");
     try
     {
         var list = new List <GestureRecognizer>()
         {
             new GestureRecognizer()
         };
         var ret = EnumerableExtensions.Append <GestureRecognizer>(list, new GestureRecognizer());
         Assert.IsNotNull(ret, "should not be null");
     }
     catch (Exception e)
     {
         Assert.Fail("Catch exception: " + e.Message.ToString());
     }
     tlog.Debug(tag, $"Append END");
 }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        public void Add(TFirst first, TSecond second)
        {
            IEnumerable <TSecond> secondList;

            if (!Forward.TryGetValue(first, out secondList))
            {
                secondList     = new List <TSecond>();
                Forward[first] = secondList;
            }

            IEnumerable <TFirst> firstList;

            if (!Backward.TryGetValue(second, out firstList))
            {
                firstList        = new List <TFirst>();
                Backward[second] = firstList;
            }

            Forward[first]   = EnumerableExtensions.Append(secondList, second);
            Backward[second] = EnumerableExtensions.Append(firstList, first);
        }