Exemple #1
0
 public static Object StrDup(int Number, Object Character)
 {
     if (Number < 0)
     {
         throw new ArgumentException
                   (S._("VB_NonNegative"), "Number");
     }
     if (Character == null)
     {
         throw new ArgumentNullException("Character");
     }
     else if (Character is String)
     {
         return(StrDup(Number, (String)Character));
     }
     else if (Character is Char)
     {
         return(StrDup(Number, (Char)Character));
     }
     else
     {
         try
         {
             return(StrDup(Number, CharType.FromObject(Character)));
         }
         catch (Exception)
         {
             throw new ArgumentException
                       (S._("VB_NotAChar"), "Character");
         }
     }
 }
 public void FromObject_ThrowsOverflowException(object value)
 {
     Assert.Throws <OverflowException>(() => CharType.FromObject(value));
 }
 public void FromObject_ThrowsInvalidCastException(object value)
 {
     Assert.Throws <InvalidCastException>(() => CharType.FromObject(value));
 }
 public void FromObject_NotSupported(object value, char expected)
 {
     Assert.Throws <InvalidCastException>(() => CharType.FromObject(value));
 }
 public void FromObject(object value, char expected)
 {
     Assert.Equal(expected, CharType.FromObject(value));
 }