Exemplo n.º 1
0
        public void EmptyInputForNullableReturnsNull()
        {
            Type lNullableType = typeof(int?);

            foreach (var lPermation in OptionsPermutation.GetAll((int?)342))
            {
                Assert.Null(fnTo(null, lNullableType, lPermation.ConvertOptions, lPermation.IgnoreError, lPermation.DefaultValue));
            }
        }
Exemplo n.º 2
0
        public void ImmediateReturnTargetValueType()
        {
            int lIntValue = 42;

            foreach (var lPermation in OptionsPermutation.GetAll(923))
            {
                Assert.Equal(lIntValue, fnTo(lIntValue, typeof(int), lPermation.ConvertOptions, lPermation.IgnoreError, lPermation.DefaultValue));
            }
        }
Exemplo n.º 3
0
        public void ImmediateReturnTargetReferenceType()
        {
            string lSourceValue = "foo bar baz";

            foreach (var lPermation in OptionsPermutation.GetAll("a different string"))
            {
                Assert.Same(lSourceValue, fnTo(lSourceValue, typeof(string), lPermation.ConvertOptions, lPermation.IgnoreError, lPermation.DefaultValue));
            }
        }
Exemplo n.º 4
0
        public void ImmediateReturnNullForNullReference()
        {
            Type ltRefType = typeof(object);

            foreach (var lPermation in OptionsPermutation.GetAll(new object()))
            {
                Assert.Null(fnTo(null, ltRefType, lPermation.ConvertOptions, lPermation.IgnoreError, lPermation.DefaultValue));
            }
        }
Exemplo n.º 5
0
        public void NonEmptyInputForNullableReturnsUnderlyingValue_Enum()
        {
            Type lNullableType = typeof(TestShortEnum?);

            foreach (var lPermation in OptionsPermutation.GetAll((TestShortEnum?)TestShortEnum.One))
            {
                foreach (object lInput in ConvertTestData.Int49Inputs)
                {
                    object lResult = fnTo(lInput, lNullableType, lPermation.ConvertOptions, lPermation.IgnoreError, lPermation.DefaultValue);
                    Assert.IsAssignableFrom <TestShortEnum>(lResult);
                    Assert.Equal(TestShortEnum.FortyNine, (TestShortEnum)lResult);
                }
            }
        }
Exemplo n.º 6
0
        public void NonEmptyInputForNullableReturnsUnderlyingValue_Int()
        {
            Type lNullableType = typeof(int?);

            foreach (var lPermation in OptionsPermutation.GetAll((int?)342))
            {
                foreach (object lInput in ConvertTestData.Int49Inputs)
                {
                    object lResult = fnTo(lInput, lNullableType, lPermation.ConvertOptions, lPermation.IgnoreError, lPermation.DefaultValue);
                    Assert.IsAssignableFrom <int>(lResult);
                    Assert.Equal(49, (int)lResult);
                }
            }
        }