Пример #1
0
        public void DoesNotSetNull()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            list.Add("a");
            Assert.Throws <ArgumentNullException>(() => list[0] = null);
        }
Пример #2
0
        public void DoesNotAddRangeWithNull()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            // TODO(jonskeet): Change to ArgumentException? The argument isn't null...
            Assert.Throws <ArgumentNullException>(() => list.Add(new[] { "a", "b", null }));
        }
Пример #3
0
        public void NonMutatingOperationsOnFluidList()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            Assert.IsFalse(list.Contains(""));
            Assert.AreEqual(0, list.Count);
            list.CopyTo(new string[5], 0);
            list.GetEnumerator();
            Assert.AreEqual(-1, list.IndexOf(""));
            Assert.IsFalse(list.IsReadOnly);
        }
Пример #4
0
        public void MutatingOperationsOnFluidList()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            list.Add("");
            list.Clear();
            list.Insert(0, "");
            list.Remove("");
            list.Add("x"); // Just to make the next call valid
            list.RemoveAt(0);
        }
Пример #5
0
        public void MutatingOperationsOnFrozenList()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            list.MakeReadOnly();
            AssertNotSupported(() => list.Add(""));
            AssertNotSupported(() => list.Clear());
            AssertNotSupported(() => list.Insert(0, ""));
            AssertNotSupported(() => list.Remove(""));
            AssertNotSupported(() => list.RemoveAt(0));
        }
        public void DoesNotAddNull()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            try
            {
                list.Add((string)null);
            }
            catch (ArgumentNullException)
            { return; }

            Assert.Fail("List should not allow nulls.");
        }
        public void DoesNotAddRangeWithNull()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            try
            {
                list.Add(new[] { "a", "b", null });
            }
            catch (ArgumentNullException)
            { return; }

            Assert.Fail("List should not allow nulls.");
        }
Пример #8
0
        public void DoesNotAddNullEnumerable()
        {
            PopsicleList <string> list = new PopsicleList <string>();

            Assert.Throws <ArgumentNullException>(() => list.Add((IEnumerable <string>)null));
        }