Exemplo n.º 1
0
        public void CanRemoveFromEmptyList()
        {
            var  list    = new RecentCollection <int>(10);
            bool removed = list.Remove(int.MaxValue);

            Assert.IsFalse(removed);
            Assert.AreEqual(0, list.Count);
        }
Exemplo n.º 2
0
        public void CanRemoveNonExistingStringElement()
        {
            var list = new RecentCollection <string>(10)
            {
                "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle"
            };
            int oldCount = list.Count;

            bool removed = list.Remove("There is no spoon");

            Assert.IsFalse(removed);
            Assert.AreEqual(oldCount, list.Count);
        }
Exemplo n.º 3
0
        public void CanRemoveNonExistingInt32Element()
        {
            var list = new RecentCollection <int>(10)
            {
                1, 2, 3, 4, 5
            };
            int oldCount = list.Count;

            bool removed = list.Remove(1024);

            Assert.IsFalse(removed);
            Assert.AreEqual(oldCount, list.Count);
        }
Exemplo n.º 4
0
        public void CanRemoveLastStringElement()
        {
            var list = new RecentCollection <string>(10)
            {
                "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle"
            };
            int oldCount = list.Count;

            bool removed = list.Remove("Neo");

            Assert.IsTrue(removed);
            Assert.AreEqual(oldCount - 1, list.Count);

            // TODO: Use SequenceEqual
            string[] temp = new[] { "Morpheus", "Trinity", "Agent Smith", "Oracle" }.Reverse().ToArray();
            for (int i = 0; i < temp.Length; i++)
            {
                Assert.AreEqual(temp[i], list[i]);
            }
        }
Exemplo n.º 5
0
        public void CanRemoveMiddleInt32Element()
        {
            var list = new RecentCollection <int>(5)
            {
                1, 2, 3, 4, 5
            };
            int oldCount = list.Count;

            bool removed = list.Remove(3);

            Assert.IsTrue(removed);
            Assert.AreEqual(oldCount - 1, list.Count);

            // TODO: Use SequenceEqual
            int[] temp = new[] { 1, 2, 4, 5 }.Reverse().ToArray();
            for (int i = 0; i < temp.Length; i++)
            {
                Assert.AreEqual(temp[i], list[i]);
            }
        }
Exemplo n.º 6
0
        public void CanRemoveFirstInt32Element()
        {
            var list = new RecentCollection<int>(5) {1, 2, 3, 4, 5};
            int oldCount = list.Count;

            bool removed = list.Remove(5);

            Assert.IsTrue(removed);
            Assert.AreEqual(oldCount - 1, list.Count);

            // TODO: Use SequenceEqual
            int[] temp = new[] { 1, 2, 3, 4 }.Reverse().ToArray();
            for (int i = 0; i < temp.Length; i++)
            {
                Assert.AreEqual(temp[i], list[i]);
            }
        }
Exemplo n.º 7
0
        public void CanRemoveNonExistingStringElement()
        {
            var list = new RecentCollection<string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" };
            int oldCount = list.Count;

            bool removed = list.Remove("There is no spoon");

            Assert.IsFalse(removed);
            Assert.AreEqual(oldCount, list.Count);
        }
Exemplo n.º 8
0
        public void CanRemoveNonExistingInt32Element()
        {
            var list = new RecentCollection<int>(10) { 1, 2, 3, 4, 5 };
            int oldCount = list.Count;

            bool removed = list.Remove(1024);

            Assert.IsFalse(removed);
            Assert.AreEqual(oldCount, list.Count);
        }
Exemplo n.º 9
0
        public void CanRemoveMiddleStringElement()
        {
            var list = new RecentCollection<string>(10) { "Neo", "Morpheus", "Trinity", "Agent Smith", "Oracle" };
            int oldCount = list.Count;

            bool removed = list.Remove("Trinity");

            Assert.IsTrue(removed);
            Assert.AreEqual(oldCount - 1, list.Count);

            // TODO: Use SequenceEqual
            string[] temp = new[] { "Neo", "Morpheus", "Agent Smith", "Oracle" }.Reverse().ToArray();
            Assert.IsTrue(temp.SequenceEqual(list));
            //for (int i = 0; i < temp.Length; i++)
            //{
            //    Assert.AreEqual(temp[i], list[i]);
            //}
        }
Exemplo n.º 10
0
        public void CanRemoveFromEmptyList()
        {
            var list = new RecentCollection<int>(10);
            bool removed = list.Remove(int.MaxValue);

            Assert.IsFalse(removed);
            Assert.AreEqual(0, list.Count);
        }