public void NonNullCollection_ToArray_1() { NonNullCollection <string> collection = new NonNullCollection <string>(); string[] array = collection.ToArray(); Assert.AreEqual(0, array.Length); }
public void BinaryReaderUtility_ReadCollectionT_1() { MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); NonNullCollection <Dummy> expected = new NonNullCollection <Dummy> { new Dummy { Value = 123 }, new Dummy { Value = 456 }, new Dummy { Value = 789 } }; BinaryWriterUtility.Write(writer, expected); byte[] bytes = stream.ToArray(); stream = new MemoryStream(bytes); BinaryReader reader = new BinaryReader(stream); NonNullCollection <Dummy> actual = new NonNullCollection <Dummy>(); BinaryReaderUtility.ReadCollection(reader, actual); Assert.AreEqual(expected.Count, actual.Count); Assert.AreEqual(expected[0].Value, actual[0].Value); Assert.AreEqual(expected[1].Value, actual[1].Value); Assert.AreEqual(expected[2].Value, actual[2].Value); }
/// <summary> /// Internal constructor. /// </summary> internal MenuFile ( NonNullCollection <MenuEntry> entries ) { Entries = entries; }
public void NonNullCollection_Unit_Add_ItemIsNull() { NonNullCollection<String> target = new NonNullCollection<String>(); String item = null; target.Add(item); }
public void NonNullCollection_Unit_Add_Optimal() { NonNullCollection<String> target = new NonNullCollection<String>(); String item = "Test"; target.Add(item); CollectionAssert.Contains(target, item); }
/// <summary> /// Constructor. /// </summary> public WriteRecordsCommand ( [NotNull] IIrbisConnection connection ) : base(connection) { References = new NonNullCollection <RecordReference>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="connection"></param> public ReadFileCommand ( [NotNull] IIrbisConnection connection ) : base(connection) { _files = new NonNullCollection <FileSpecification>(); }
/// <inheritdoc cref="IHandmadeSerializable.RestoreFromStream" /> public void RestoreFromStream ( BinaryReader reader ) { _name = reader.ReadNullableString(); _lines = reader.ReadNonNullCollection <Line>(); }
/// <summary> /// Constructor. /// </summary> public ListFilesCommand ( [NotNull] IIrbisConnection connection ) : base(connection) { _specifications = new NonNullCollection <FileSpecification>(); }
public void NonNullCollection_Indexer_1a() { NonNullCollection <object> collection = new NonNullCollection <object> { new object() }; collection[0] = null; }
public void NonNullCollection_ToArray_2() { NonNullCollection <string> collection = new NonNullCollection <string>(); collection.Add("hello"); string[] array = collection.ToArray(); Assert.AreEqual(1, array.Length); Assert.AreEqual("hello", array[0]); }
public void NonNullCollection_Add_1() { NonNullCollection <object> collection = new NonNullCollection <object> { new object() }; Assert.AreEqual(1, collection.Count); }
public void NonNullCollection_Add_1a() { NonNullCollection <object> collection = new NonNullCollection <object> { null }; Assert.AreEqual(0, collection.Count); }
internal Section ( [NotNull] IniFile owner, [CanBeNull] string name ) { Owner = owner; _name = name; _lines = new NonNullCollection <Line>(); }
public void NonNullCollection_Indexer_1() { NonNullCollection <object> collection = new NonNullCollection <object> { new object() }; collection[0] = 1; Assert.AreEqual(1, collection[0]); }
public void NonNullCollection_EnsureCapacity_1() { NonNullCollection <object> collection = new NonNullCollection <object> { new object() }; collection.EnsureCapacity(100); Assert.IsTrue(collection.Capacity >= 100); }
/// <summary> /// Constructor. /// </summary> public GblSettings() { Actualize = true; Autoin = false; FirstRecord = 1; FormalControl = false; MaxMfn = 0; MinMfn = 0; Statements = new NonNullCollection <GblStatement>(); }
public void NonNullCollection_Clear_1() { NonNullCollection <object> collection = new NonNullCollection <object> { new object() }; collection.Clear(); Assert.AreEqual(0, collection.Count); }
/// <summary> /// Constructor. /// </summary> public UniversalTextCommand ( [NotNull] IIrbisConnection connection, [NotNull] string commandCode ) : base(connection) { Sure.NotNull(connection, nameof(connection)); Sure.NotNullNorEmpty(commandCode, nameof(commandCode)); CommandCode = commandCode; TextLines = new NonNullCollection <TextWithEncoding>(); }
public void RemoveAt_OfAnInstanceInitializedWithNormalList_DoesNotThrowException() { // Arrange var c0 = new NonNullCollection <IUnit>(new IUnit[] { MutableUnit.Create("foo"), MutableUnit.Create("bar") }.ToList()); // Act c0.RemoveAt(1); // Assert Assert.That(c0.Count, Is.EqualTo(1)); }
public void RemoveAt_OfAnInstanceInitializedWithReadOnlyList_ThrowsException() { // Arrange var c0 = new NonNullCollection <IUnit>(new IUnit[] { MutableUnit.Create("foo"), MutableUnit.Create("bar") }.ToList().AsReadOnly()); // Act // Assert Assert.That(() => { c0.RemoveAt(1); }, Throws.InstanceOf <NotSupportedException>()); }
/// <summary> /// Write the <see cref="NonNullCollection{T}"/> /// to the stream. /// </summary> public static BinaryWriter Write <T> ( [NotNull] this BinaryWriter writer, [NotNull] NonNullCollection <T> collection ) where T : class, IHandmadeSerializable, new() { Code.NotNull(writer, "writer"); writer.WriteArray(collection.ToArray()); return(writer); }
public static NonNullCollection <T> ReadNonNullCollection <T> ( [NotNull] this BinaryReader reader ) where T : class, IHandmadeSerializable, new () { Sure.NotNull(reader, nameof(reader)); T[] array = reader.ReadArray <T>(); NonNullCollection <T> result = new NonNullCollection <T>(); result.AddRange(array); return(result); }
public void NonNullCollection_AddRange_4() { NonNullCollection <object> collection = new NonNullCollection <object>(); collection.AddRange ( new[] { new object(), null, new object() } ); }
/// <summary> /// Constructor. /// </summary> /// <param name="name"></param> /// <param name="value"></param> public Parameter ( [NotNull] string name, [CanBeNull] string value ) { Sure.NotNullNorEmpty(name, nameof(name)); Name = name; Value = value ?? string.Empty; Values = new NonNullCollection <string> { Value }; }
public static MenuFile FromJson ( [NotNull] string text ) { Sure.NotNullNorEmpty(text, nameof(text)); NonNullCollection <MenuEntry> entries = JsonConvert .DeserializeObject <NonNullCollection <MenuEntry> > ( text ); MenuFile result = new MenuFile(entries); return(result); }
public void NonNullCollection_AddRange_3() { NonNullCollection <object> collection = new NonNullCollection <object>(); collection.AddRange ( (IList <object>) new[] { new object(), new object(), new object() } ); Assert.AreEqual(3, collection.Count); }
public static BinaryWriter WriteCollection <T> ( [NotNull] this BinaryWriter writer, [NotNull][ItemNotNull] NonNullCollection <T> collection ) where T : class, IHandmadeSerializable, new() { Code.NotNull(writer, "writer"); Code.NotNull(collection, "collection"); writer.WritePackedInt32(collection.Count); for (int i = 0; i < collection.Count; i++) { T item = collection[i]; item.SaveToStream(writer); } return(writer); }
/// <inheritdoc cref="JsonConverter.ReadJson" /> public override object ReadJson ( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer ) { MenuFile menu = (MenuFile)existingValue; NonNullCollection <MenuEntry> entries = serializer .Deserialize <NonNullCollection <MenuEntry> > ( reader ); menu.Entries.AddRange(entries); return(menu); }
/// <inheritdoc cref="IHandmadeSerializable.RestoreFromStream" /> public void RestoreFromStream ( BinaryReader reader ) { Sure.NotNull(reader, nameof(reader)); Actualize = reader.ReadBoolean(); Autoin = reader.ReadBoolean(); Database = reader.ReadNullableString(); FileName = reader.ReadNullableString(); FirstRecord = reader.ReadPackedInt32(); FormalControl = reader.ReadBoolean(); MaxMfn = reader.ReadPackedInt32(); MfnList = reader.ReadNullableInt32Array(); MinMfn = reader.ReadPackedInt32(); NumberOfRecords = reader.ReadPackedInt32(); SearchExpression = reader.ReadNullableString(); Statements = reader.ReadNonNullCollection <GblStatement>(); }
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); }
private static void _WriteLevel ( TextWriter writer, NonNullCollection <Item> items, int level ) { foreach (Item item in items) { for (int i = 0; i < level; i++) { writer.Write(Indent); } writer.WriteLine(item.Value); _WriteLevel ( writer, item.Children, level + 1 ); } }
public void NonNullCollection_Unit_Insert_Optimal() { NonNullCollection<String> target = new NonNullCollection<String>(); Int32 index = 0; String item = "Test"; target.Insert(index, item); CollectionAssert.Contains(target, item); }
public void NonNullCollection_Unit_Indexer_ValueIsNull() { IList<String> list = new List<String>() { "One", "Two", "Three" }; NonNullCollection<String> target = new NonNullCollection<String>(list); String value = null; target[0] = value; }
public void NonNullCollection_Unit_Insert_ItemIsNull() { NonNullCollection<String> target = new NonNullCollection<String>(); Int32 index = 0; String item = null; target.Insert(index, item); }
public void NonNullCollection_Unit_Indexer_Optimal() { IList<String> list = new List<String>() { "One", "Two", "Three" }; NonNullCollection<String> target = new NonNullCollection<String>(list); String value = "Test"; target[0] = value; Assert.AreEqual(value, target[0]); }