コード例 #1
0
        public void GetObjectValueStringToInt()
        {
            object result = TypeDescriptionHelper.GetObjectValue("1", typeof(int), String.Empty);

            Assert.IsTrue(result is int);
            Assert.AreEqual(1, result);
        }
コード例 #2
0
        public void GetObjectValueStringToBool()
        {
            object result = TypeDescriptionHelper.GetObjectValue("true", typeof(bool), String.Empty);

            Assert.IsTrue(result is bool);
            Assert.IsTrue((bool)result);
        }
コード例 #3
0
        public void GetObjectValueNotStringReturnsValue()
        {
            object result = TypeDescriptionHelper.GetObjectValue((int)1, typeof(bool), String.Empty);

            Assert.IsTrue(result is int);
            Assert.AreEqual(1, result);
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        public void GetObjectValueIfValueIsInstanceOfTargetTypeReturnsValue()
        {
            object result = TypeDescriptionHelper.GetObjectValue("1", typeof(string), String.Empty);

            Assert.AreEqual("1", result);
        }
コード例 #6
0
        public void GetObjectValueReturnsNullIfValueIsNull()
        {
            object result = TypeDescriptionHelper.GetObjectValue(null, typeof(string), String.Empty);

            Assert.IsNull(result);
        }
コード例 #7
0
 public void GetObjectValueThrowsIfNullTargetType()
 {
     TypeDescriptionHelper.GetObjectValue("2", null, String.Empty);
 }
コード例 #8
0
 public void GetObjectValueThrowsIfInvalidStringToInt()
 {
     object result = TypeDescriptionHelper.GetObjectValue("a", typeof(int), String.Empty);
 }