コード例 #1
0
        public void RemoveAt()
        {
            double[] numbers;
            TestingAPIs.ListOfDoubles list;

            bool ok;

            do
            {
                list = new TestingAPIs.ListOfDoubles(10, out numbers);

                ok = true;
                for (int i = 0; i < list.Count; i++)
                {
                    if (i != 5)
                    {
                        if (numbers[i] == numbers[5])
                        {
                            ok = false;
                        }
                    }
                }
            } while (!ok);

            list.RemoveAt(5);

            var field = (List <double>) new PrivateObject(list).GetField("list");

            Assert.AreEqual(9, field.Count);

            for (int i = 0; i < field.Count; i++)
            {
                Assert.AreNotEqual(numbers[5], field[i]);
            }
        }
コード例 #2
0
        public void GetAt()
        {
            double[] numbers;
            var      list = new TestingAPIs.ListOfDoubles(10, out numbers);

            Assert.AreEqual(numbers[5], list.GetAt(5));
        }
コード例 #3
0
        public void Removing()
        {
            double[] numbers;
            var      list = new TestingAPIs.ListOfDoubles(10, out numbers);

            list.Remove(numbers[5]);
            var field = (List <double>) new PrivateObject(list).GetField("list");

            Assert.AreEqual(9, field.Count);

            int index = 0;

            for (int i = 0; i < field.Count; i++)
            {
                if (i != 5)
                {
                    if (field[i] != numbers[index])
                    {
                        throw new AssertFailedException("Error when removing");
                    }

                    index++;
                }
                else
                {
                    index += 2;
                }
            }
        }
コード例 #4
0
        public void Count()
        {
            var list = new TestingAPIs.ListOfDoubles(10);

            if (list.Count != 10)
            {
                throw new AssertFailedException("Count does not return correct number of items in list");
            }
        }
コード例 #5
0
        public void Adding()
        {
            var list = new TestingAPIs.ListOfDoubles(0);

            foreach (var item in TestingAPIs.ListOfDoubles.Numbers(10))
            {
                list.Add(item);
            }

            var field = (List <double>) new PrivateObject(list).GetField("list");

            Assert.IsNotNull(field);
        }
コード例 #6
0
        public void Clear()
        {
            var list = new TestingAPIs.ListOfDoubles(10);

            list.Clear();

            var field = (List <double>) new PrivateObject(list).GetField("list");

            if (field.Count > 0)
            {
                throw new AssertFailedException("The list is not clear");
            }
        }
コード例 #7
0
        public void Find()
        {
            double[] numbers;
            var      list = new TestingAPIs.ListOfDoubles(10, out numbers);

            if (!list.Find(numbers[5]))
            {
                throw new AssertFailedException("Can't find number in list");
            }

            var field = (List <double>) new PrivateObject(list).GetField("list");

            Assert.AreEqual(numbers[5], field[5]);
        }
コード例 #8
0
        public void Update()
        {
            var  list = new TestingAPIs.ListOfDoubles(10);
            bool ok   = list.Update(489.56145D, 5);

            if (!ok)
            {
                throw new AssertFailedException("List has not been updated");
            }

            var field = (List <double>) new PrivateObject(list).GetField("list");

            Assert.AreEqual(489.56145D, field[5]);
        }