public void NonNullCollection_Clear_1() { NonNullCollection <object> collection = new NonNullCollection <object> { new object() }; collection.Clear(); Assert.AreEqual(0, collection.Count); }
public void Clear_OfAnInstanceInitializedWithReadOnlyList_ThrowsException() { // Arrange var c0 = new NonNullCollection <IUnit>(new IUnit[] { MutableUnit.Create("foo"), MutableUnit.Create("bar") }.ToList().AsReadOnly()); // Act // Assert Assert.That(() => { c0.Clear(); }, Throws.InstanceOf <NotSupportedException>()); }
public void Clear_OfAnInstanceInitializedWithNormalList_DoesNotThrowException() { // Arrange var c0 = new NonNullCollection <IUnit>(new IUnit[] { MutableUnit.Create("foo"), MutableUnit.Create("bar") }.ToList()); // Act c0.Clear(); // Assert Assert.That(c0.Count, Is.EqualTo(0)); }
public static BinaryReader ReadCollection <T> ( [NotNull] this BinaryReader reader, [NotNull] NonNullCollection <T> collection ) where T : class, IHandmadeSerializable, new() { Sure.NotNull(reader, nameof(reader)); Sure.NotNull(collection, nameof(collection)); collection.Clear(); int count = reader.ReadPackedInt32(); for (int i = 0; i < count; i++) { T item = new T(); item.RestoreFromStream(reader); collection.Add(item); } return(reader); }
/// <summary> /// Clear the INI-file. /// </summary> public IniFile Clear() { _sections.Clear(); return(this); }
/// <summary> /// Clear the section. /// </summary> public void Clear() { _lines.Clear(); Modified = true; Owner.Modified = true; }