public CreateNavigator ( object data, |
||
data | object | |
pathType | ||
Результат | INavigator |
public INavigator CreateNavigator(object data, Type pathType)
{
if (!pathType.GetInterfaces().Contains(typeof (IPath)))
{
throw new Exception("'" + pathType + "' doesn't implement '" + typeof (IPath) + "'");
}
INavigator navigator;
if (pathType == typeof (XmlPath))
{
navigator = new XmlNavigator(data);
}
else if (pathType == typeof (JsonPath))
{
navigator = new JsonNavigator(data);
}
else if (pathType == typeof (PocoPath))
{
navigator = new PocoNavigator(data);
}
else if( pathType == typeof(StringPath))
{
navigator = new StringNavigator(data);
}
else
{
navigator = null;
}
return navigator;
}
public void CreateNavigator_Expected_XmlNavigator() { StringInterrogator stringInterrogator = new StringInterrogator(); INavigator navigator = stringInterrogator.CreateNavigator(XmlGiven(), typeof(XmlPath)); Type expected = typeof(XmlNavigator); Type actual = navigator.GetType(); Assert.AreEqual(expected, actual); }