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

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

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