Ejemplo n.º 1
0
        public void RemoveItems()
        {
            var list = new ListHistory <string>
            {
                "a",
                "b",
                "c",
                "d",
                "e",
                "f",
            };

            list.Remove("a");
            Assert.IsFalse(list.Contains("a"));

            list.Remove("b");
            Assert.IsFalse(list.Contains("b"));

            list.Remove("c");
            Assert.IsFalse(list.Contains("c"));

            list.Remove("d");
            Assert.IsFalse(list.Contains("d"));

            list.Remove("e");
            Assert.IsFalse(list.Contains("e"));

            list.Remove("f");
            Assert.IsFalse(list.Contains("f"));
        }
Ejemplo n.º 2
0
        public void RemoveItemsAtInvalidIndex()
        {
            var list = new ListHistory <string>
            {
                "a",
                "b",
                "c",
                "d",
                "e",
                "f",
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveAt(-1));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveAt(list.Count));
        }
Ejemplo n.º 3
0
        public void InsertItemsAtInvalidIndex()
        {
            var list = new ListHistory <string>
            {
                "a",
                "b",
                "c",
                "d",
                "e",
                "f",
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => list.Insert(-1, "aa"));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.Insert(list.Count + 1, "bb"));
        }
Ejemplo n.º 4
0
        public void IndexerGetItemsAtInvalidIndex()
        {
            var list = new ListHistory <string>
            {
                "a",
                "b",
                "c",
                "d",
                "e",
                "f",
            };

            Assert.Throws <ArgumentOutOfRangeException>(
                () =>
            {
                var result = list[-1];

                // We're not expecting to get this far but code analysis says that
                // we shouldn't have unused locals, unfortunately the compiler doesn't
                // like it when we remove the local, so ..
                Assert.IsNull(result);
                Assert.Fail();
            });

            Assert.Throws <ArgumentOutOfRangeException>(
                () =>
            {
                var result = list[list.Count];

                // We're not expecting to get this far but code analysis says that
                // we shouldn't have unused locals, unfortunately the compiler doesn't
                // like it when we remove the local, so ..
                Assert.IsNull(result);
                Assert.Fail();
            });
        }