public void Prepend_Successful()
        {
            var item         = new { Id = 1, Value = "string1" };
            var originalList = new List <object>
            {
                new { Id = 2, Value = "string2" },
                null,
                new { Id = 3, Value = "string3" },
            };

            var result = EnumerableExtension.Prepend(originalList, item).ToList();

            Assert.AreEqual(originalList.Count + 1, result.Count);
            AssertExtension.AreObjectsValuesEqual(item, result[0]);
            for (int i = 0; i < originalList.Count; i++)
            {
                AssertExtension.AreObjectsValuesEqual(originalList[i], result[i + 1]);
            }
        }
Beispiel #2
0
        /// <inheritdoc />
        public IEnumerable <TValue> Traverse()
        {
            var traversedChildren = Children.SelectMany(n => n.Traverse());

            return(EnumerableExtension.Prepend(traversedChildren, Item));
        }