TestParameters
TestParameters class holds any named parameters supplied to the test run
using System;
using System.Collections.Generic;
namespace NUnit.Framework
{
public class TestParameters
{
private readonly Dictionary<string, string> _parameters = new Dictionary<string, string>();
public int Count => _parameters.Count;
public ICollection<string> Names => _parameters.Keys;
public string this[string name] {
get {
return Get(name);
}
}
public bool Exists(string name)
{
return _parameters.ContainsKey(name);
}
public string Get(string name)
{
if (!Exists(name))
return null;
return _parameters[name];
}
public string Get(string name, string defaultValue)
{
return Get(name) ?? defaultValue;
}
public T Get<T>(string name, T defaultValue)
{
string text = Get(name);
if (text == null)
return defaultValue;
return (T)Convert.ChangeType(text, typeof(T), null);
}
internal void Add(string name, string value)
{
_parameters[name] = value;
}
}
}