Beispiel #1
0
        public TValue GetValue <TValue>()
        {
            var castConverter = new CastConverter <TValue>();

            if (Converter == null)
            {
                return(castConverter.Convert(getValue()));
            }
            else
            {
                return(castConverter.Convert(Converter.ConvertToObject(getValue())));
            }
        }
Beispiel #2
0
 public void DoubleToEnum_Exception()
 {
     var    doubleValue = (double)System.IO.SeekOrigin.Current;
     var    targetType  = typeof(System.IO.SeekOrigin);
     var    sut         = new CastConverter(targetType);
     object actual      = sut.Convert(doubleValue, targetType, null, CultureInfo.CurrentCulture);
 }
Beispiel #3
0
 public void InvalidStringToEnum_Exception()
 {
     var stringValue = "";
     var targetType  = typeof(System.IO.SeekOrigin);
     var sut         = new CastConverter(targetType);
     var actual      = sut.Convert(stringValue, targetType, null, CultureInfo.CurrentCulture);
 }
Beispiel #4
0
        public void OutOfRangeIntToEnum()
        {
            const int valueNotInEnum = 100;
            var       expected       = (System.IO.SeekOrigin)valueNotInEnum;
            var       targetType     = typeof(System.IO.SeekOrigin);
            var       sut            = new CastConverter(targetType);
            var       actual         = sut.Convert(valueNotInEnum, targetType, null, CultureInfo.CurrentCulture);

            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
        public void StringNumberToEnum()
        {
            var expected    = System.IO.SeekOrigin.Current;
            var stringValue = ((int)expected).ToString();
            var targetType  = typeof(System.IO.SeekOrigin);
            var sut         = new CastConverter(targetType);
            var actual      = sut.Convert(stringValue, targetType, null, CultureInfo.CurrentCulture);

            Assert.AreEqual(expected, actual);
        }