public void TestModifyDefaultInstance()
        {
            //verify that the default instance has correctly been marked as read-only
            Assert.AreEqual(typeof(PopsicleList <bool>), TestAllTypes.DefaultInstance.RepeatedBoolList.GetType());
            PopsicleList <bool> list = (PopsicleList <bool>)TestAllTypes.DefaultInstance.RepeatedBoolList;

            Assert.IsTrue(list.IsReadOnly);
        }
 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);
 }
Beispiel #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);
 }
 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 DoesNotAddNullEnumerable()
        {
            PopsicleList<string> list = new PopsicleList<string>();
            try
            {
                list.Add((IEnumerable<string>)null);
            }
            catch (ArgumentNullException)
            { return; }

            Assert.Fail("List should not allow nulls.");
        }
        public void DoesNotSetNull()
        {
            PopsicleList<string> list = new PopsicleList<string>();
            list.Add("a");
            try
            {
                list[0] = 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.");
        }
Beispiel #8
0
 public void DoesNotAddNullEnumerable()
 {
     PopsicleList<string> list = new PopsicleList<string>();
     Assert.Throws<ArgumentNullException>(() => list.Add((IEnumerable<string>) null));
 }
Beispiel #9
0
 public void DoesNotSetNull()
 {
     PopsicleList<string> list = new PopsicleList<string>();
     list.Add("a");
     Assert.Throws<ArgumentNullException>(() => list[0] = null);
 }
Beispiel #10
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}));
 }