Esempio n. 1
0
        public void NonNullCollection_Clear_1()
        {
            NonNullCollection <object> collection
                = new NonNullCollection <object>
                {
                new object()
                };

            collection.Clear();
            Assert.AreEqual(0, collection.Count);
        }
Esempio n. 2
0
        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>());
        }
Esempio n. 3
0
        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);
        }
Esempio n. 5
0
        /// <summary>
        /// Clear the INI-file.
        /// </summary>
        public IniFile Clear()
        {
            _sections.Clear();

            return(this);
        }
Esempio n. 6
0
 /// <summary>
 /// Clear the section.
 /// </summary>
 public void Clear()
 {
     _lines.Clear();
     Modified       = true;
     Owner.Modified = true;
 }