public void Clear_ReadOnly() { UnitTestNameObjectCollectionBase coll = new UnitTestNameObjectCollectionBase(); coll._IsReadOnly = true; try { // even if we're empty coll.Clear(); Assert.Fail("#1"); } catch (NotSupportedException ex) { // Collection is read-only Assert.AreEqual(typeof(NotSupportedException), ex.GetType(), "#2"); Assert.IsNull(ex.InnerException, "#3"); Assert.IsNotNull(ex.Message, "#4"); } }
public void Constructor_Int() { UnitTestNameObjectCollectionBase coll = new UnitTestNameObjectCollectionBase(0); for (int i = 0; i < 10; i++) { coll.Add(i.ToString(), i); } CheckICollection(coll, 10); Assert.AreEqual(10, coll.Keys.Count, "Keys"); coll.Clear(); Assert.AreEqual(0, coll.Count, "Count"); Assert.IsFalse(coll.HasKeys(), "HasKeys"); }
public void Clear_ReadOnly () { UnitTestNameObjectCollectionBase coll = new UnitTestNameObjectCollectionBase (); coll._IsReadOnly = true; try { // even if we're empty coll.Clear (); Assert.Fail ("#1"); } catch (NotSupportedException ex) { // Collection is read-only Assert.AreEqual (typeof (NotSupportedException), ex.GetType (), "#2"); Assert.IsNull (ex.InnerException, "#3"); Assert.IsNotNull (ex.Message, "#4"); } }
public void Constructor_Int () { UnitTestNameObjectCollectionBase coll = new UnitTestNameObjectCollectionBase (0); for (int i = 0; i < 10; i++) coll.Add (i.ToString (), i); CheckICollection (coll, 10); Assert.AreEqual (10, coll.Keys.Count, "Keys"); coll.Clear (); Assert.AreEqual (0, coll.Count, "Count"); Assert.IsFalse (coll.HasKeys (), "HasKeys"); }