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)); } }
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)); } }
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)); } }
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)); } }
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); } } }
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); } } }