Exemplo n.º 1
0
        private static void IndexComparisonHelper <T>(params T[] data)
        {
            //Comparing to a list here just because it implements all the operations.
            //No particular reason this colleciton was chosen.
            var systemList = new List <T>(data);

            var testedList = new SingleList <T>();

            foreach (var value in systemList)
            {
                testedList.Add(value);
            }
            //Index Test
            foreach (var value in systemList)
            {
                var correctIndex = systemList.IndexOf(value);
                var testedIndex  = testedList.IndexOf(value);
                Assert.Equal(correctIndex, testedIndex);
                Assert.True(testedList.Contains(value));
            }
            //Removal Tests
            for (int i = 0; i < data.Length; i++)
            {
                //Let's check it behaves in a manner identical to deference list
                Assert.Equal(testedList.Remove(data[2]), systemList.Remove(data[2]));
                Assert.Equal(testedList.Count, systemList.Count);
            }
        }