#define PORTABLE
#define TIZEN
#define NUNIT_FRAMEWORK
#define NUNITLITE
#define NET_4_5
#define PARALLEL
using System;
using System.Collections.Generic;
using System.Text;
namespace NUnit.Framework
{
///
/// TestParameters class holds any named parameters supplied to the test run
///
public class TestParameters
{
private readonly Dictionary _parameters = new Dictionary();
///
/// Gets the number of test parameters
///
public int Count
{
get { return _parameters.Count; }
}
///
/// Gets a collection of the test parameter names
///
public ICollection Names
{
get { return _parameters.Keys; }
}
///
/// Gets a flag indicating whether a parameter with the specified name exists.N
///
/// Name of the parameter
/// True if it exists, otherwise false
public bool Exists(string name)
{
return _parameters.ContainsKey(name);
}
///
/// Indexer provides access to the internal dictionary
///
/// Name of the parameter
/// Value of the parameter or null if not present
public string this[string name]
{
get { return Get(name); }
}
///
/// Get method is a simple alternative to the indexer
///
/// Name of the paramter
/// Value of the parameter or null if not present
public string Get(string name)
{
return Exists(name) ? _parameters[name] : null;
}
///
/// Get the value of a parameter or a default string
///
/// Name of the parameter
/// Default value of the parameter
/// Value of the parameter or default value if not present
public string Get(string name, string defaultValue)
{
return Get(name) ?? defaultValue;
}
///
/// Get the value of a parameter or return a default
///
/// The return Type
/// Name of the parameter
/// Default value of the parameter
/// Value of the parameter or default value if not present
public T Get(string name, T defaultValue)
{
string val = Get(name);
return val != null ? (T)Convert.ChangeType(val, typeof(T), null) : defaultValue;
}
///
/// Adds a parameter to the list
///
/// Name of the parameter
/// Value of the parameter
internal void Add(string name, string value)
{
_parameters[name] = value;
}
}
}