}
[Theory]
- [MemberData(nameof(FromObject_Overflow_TestData))]
- public void FromObject_ThrowsOverflowException(object value)
- {
- Assert.Throws<OverflowException>(() => CharType.FromObject(value));
- }
-
- [Theory]
[MemberData(nameof(FromString_TestData))]
public void FromString(string value, char expected)
{
Assert.Equal(expected, CharType.FromString(value));
}
- [Theory]
- [MemberData(nameof(FromString_Invalid_TestData))]
- public void FromString_ThrowsInvalidCastException(string value)
- {
- Assert.Throws<InvalidCastException>(() => CharType.FromString(value));
- }
-
- [Theory]
- [MemberData(nameof(FromString_Overflow_TestData))]
- public void FromString_ThrowsOverflowException(string value)
- {
- Assert.Throws<OverflowException>(() => CharType.FromString(value));
- }
-
public static IEnumerable<object[]> FromObject_TestData()
{
// char.
yield return new object[] { new object() };
}
- public static IEnumerable<object[]> FromObject_Overflow_TestData()
- {
- yield break;
- }
-
public static IEnumerable<object[]> FromString_TestData()
{
yield return new object[] { null, char.MinValue };
yield return new object[] { "18446744073709551616", '1' };
yield return new object[] { "1844674407370955161618446744073709551616", '1' };
}
-
- public static IEnumerable<object[]> FromString_Invalid_TestData()
- {
- yield break;
- }
-
- public static IEnumerable<object[]> FromString_Overflow_TestData()
- {
- yield break;
- }
}
}
public static IEnumerable<object[]> Hex_Single_TestData()
{
- yield break; // Add more...
+ yield return new object[] { (float)0, "0" };
+ yield return new object[] { (float)1, "1" };
+ yield return new object[] { (float)15, "F" };
}
public static IEnumerable<object[]> Hex_Double_TestData()
{
- yield break; // Add more...
+ yield return new object[] { (double)0, "0" };
+ yield return new object[] { (double)1, "1" };
+ yield return new object[] { (double)15, "F" };
}
public static IEnumerable<object[]> Hex_Decimal_TestData()
{
- yield break; // Add more...
+ yield return new object[] { (decimal)0, "0" };
+ yield return new object[] { (decimal)1, "1" };
+ yield return new object[] { (decimal)15, "F" };
}
[Theory]
public static IEnumerable<object[]> Oct_Single_TestData()
{
- yield break; // Add more...
+ yield return new object[] { (float)0, "0" };
+ yield return new object[] { (float)1, "1" };
+ yield return new object[] { (float)15, "17" };
}
public static IEnumerable<object[]> Oct_Double_TestData()
{
- yield break; // Add more...
+ yield return new object[] { (double)0, "0" };
+ yield return new object[] { (double)1, "1" };
+ yield return new object[] { (double)15, "17" };
}
public static IEnumerable<object[]> Oct_Decimal_TestData()
{
- yield break; // Add more...
+ yield return new object[] { (decimal)0, "0" };
+ yield return new object[] { (decimal)1, "1" };
+ yield return new object[] { (decimal)15, "17" };
}
[Theory]
}
[Theory]
- [MemberData(nameof(Val_Char_ArgumentException_TestData))]
- public void Val_ArgumentException_Char(char value)
- {
- Assert.Throws<ArgumentException>(() => Conversion.Val(value));
- }
-
- [Theory]
- [MemberData(nameof(Val_Char_OverflowException_TestData))]
- public void Val_OverflowException_Char(char value)
- {
- Assert.Throws<OverflowException>(() => Conversion.Val(value));
- }
-
- [Theory]
[MemberData(nameof(Val_String_TestData))]
public void Val_String_Double(string value, double expected)
{
}
[Theory]
- [MemberData(nameof(Val_String_ArgumentException_TestData))]
- public void Val_ArgumentException_String(string value)
- {
- Assert.Throws<ArgumentException>(() => Conversion.Val(value));
- }
-
- [Theory]
[MemberData(nameof(Val_String_InvalidCastException_TestData))]
public void Val_InvalidCastException(string value)
{
public static IEnumerable<object[]> Val_Object_ArgumentException_TestData()
{
- yield break; // Add more...
+ yield return new object[] { new object() };
}
public static IEnumerable<object[]> Val_Object_OverflowException_TestData()
{
- yield break; // Add more...
+ yield return new object[] { "123456e789" };
}
public static IEnumerable<object[]> Val_Char_TestData()
yield return new object[] { char.MaxValue, 0 };
}
- public static IEnumerable<object[]> Val_Char_ArgumentException_TestData()
- {
- yield break; // Add more...
- }
-
- public static IEnumerable<object[]> Val_Char_OverflowException_TestData()
- {
- yield break; // Add more...
- }
-
public static IEnumerable<object[]> Val_String_TestData()
{
yield return new object[] { null, 0.0 };
yield return new object[] { "&O37777777777&", -1.0 };
}
- public static IEnumerable<object[]> Val_String_ArgumentException_TestData()
- {
- yield break; // Add more...
- }
-
public static IEnumerable<object[]> Val_String_InvalidCastException_TestData()
{
yield return new object[] { "1.0%" };
public static IEnumerable<object[]> Val_String_OverflowException_TestData()
{
- yield break; // Add more...
+ yield return new object[] { "123456e789" };
}
public static IEnumerable<object[]> Various_ArgumentException_TestData()
}
[Theory]
- [MemberData(nameof(FromObject_Overflow_TestData))]
- public void FromObject_ThrowsOverflowException(object value)
- {
- Assert.Throws<OverflowException>(() => DateType.FromObject(value));
- }
-
- [Theory]
[MemberData(nameof(FromString_TestData))]
public void FromString(string value, DateTime expected)
{
Assert.Throws<InvalidCastException>(() => DateType.FromString(value));
}
- [Theory]
- [MemberData(nameof(FromString_Overflow_TestData))]
- public void FromString_ThrowsOverflowException(string value)
- {
- Assert.Throws<OverflowException>(() => DateType.FromString(value));
- }
-
public static IEnumerable<object[]> FromObject_TestData()
{
// null.
public static IEnumerable<object[]> FromObject_Invalid_TestData()
{
- yield break;
- }
-
- public static IEnumerable<object[]> FromObject_Overflow_TestData()
- {
- yield break;
+ yield return new object[] { new object() };
}
public static IEnumerable<object[]> FromString_TestData()
yield return new object[] { "false" };
yield return new object[] { "invalid" };
}
-
- public static IEnumerable<object[]> FromString_Overflow_TestData()
- {
- yield break;
- }
}
}