<PackageReference Include="NUnit" Version="3.7.1" />

IPropertyBag

public interface IPropertyBag : IXmlNodeBuilder
A PropertyBag represents a collection of name/value pairs that allows duplicate entries with the same key. Methods are provided for adding a new pair as well as for setting a key to a single value. All keys are strings but _values may be of any type. Null _values are not permitted, since a null entry represents the absence of the key. The entries in a PropertyBag are of two kinds: those that take a single value and those that take multiple _values. However, the PropertyBag has no knowledge of which entries fall into each category and the distinction is entirely up to the code using the PropertyBag. When working with multi-valued properties, client code should use the Add method to add name/value pairs and indexing to retrieve a list of all _values for a given key. For example: bag.Add("Tag", "one"); bag.Add("Tag", "two"); Assert.That(bag["Tag"], Is.EqualTo(new string[] { "one", "two" })); When working with single-valued properties, client code should use the Set method to set the value and Get to retrieve the value. The GetSetting methods may also be used to retrieve the value in a type-safe manner while also providing default. For example: bag.Set("Priority", "low"); bag.Set("Priority", "high"); // replaces value Assert.That(bag.Get("Priority"), Is.EqualTo("high")); Assert.That(bag.GetSetting("Priority", "low"), Is.EqualTo("high"));
using System.Collections; using System.Collections.Generic; namespace NUnit.Framework.Interfaces { public interface IPropertyBag : IXmlNodeBuilder { IList this[string key] { get; set; } ICollection<string> Keys { get; } void Add(string key, object value); void Set(string key, object value); object Get(string key); bool ContainsKey(string key); } }