public void GetObjectValueStringToInt() { object result = TypeDescriptionHelper.GetObjectValue("1", typeof(int), String.Empty); Assert.IsTrue(result is int); Assert.AreEqual(1, result); }
public void GetObjectValueStringToBool() { object result = TypeDescriptionHelper.GetObjectValue("true", typeof(bool), String.Empty); Assert.IsTrue(result is bool); Assert.IsTrue((bool)result); }
public void GetObjectValueNotStringReturnsValue() { object result = TypeDescriptionHelper.GetObjectValue((int)1, typeof(bool), String.Empty); Assert.IsTrue(result is int); Assert.AreEqual(1, result); }
public void GetObjectValueStringToDoubleWithCultureInfoesAr() { CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("es-ar"); object result = TypeDescriptionHelper.GetObjectValue("1,2", typeof(double), String.Empty); Assert.IsTrue(result is double); Assert.AreEqual((double)1.2, result); Thread.CurrentThread.CurrentCulture = currentCulture; }
public void GetObjectValueIfValueIsInstanceOfTargetTypeReturnsValue() { object result = TypeDescriptionHelper.GetObjectValue("1", typeof(string), String.Empty); Assert.AreEqual("1", result); }
public void GetObjectValueReturnsNullIfValueIsNull() { object result = TypeDescriptionHelper.GetObjectValue(null, typeof(string), String.Empty); Assert.IsNull(result); }
public void GetObjectValueThrowsIfNullTargetType() { TypeDescriptionHelper.GetObjectValue("2", null, String.Empty); }
public void GetObjectValueThrowsIfInvalidStringToInt() { object result = TypeDescriptionHelper.GetObjectValue("a", typeof(int), String.Empty); }