28 public void ChangeType_scalars(
string testValue, Type destinationType,
bool expectFail,
object expectedResult)
34 result.
MatchNothing().Should().BeTrue(
"should fail parsing");
38 result.
MatchJust(out
object matchedValue).Should().BeTrue(
"should parse successfully");
39 Assert.Equal(matchedValue, expectedResult);
49 new object[] {
"1", typeof (
int),
false, 1},
50 new object[] {
"0", typeof (
int),
false, 0},
51 new object[] {
"-1", typeof (
int),
false, -1},
52 new object[] {
"abcd", typeof (
int),
true,
null},
53 new object[] {
"1.0", typeof (
int),
true,
null},
54 new object[] {
int.MaxValue.ToString(), typeof (
int),
false,
int.MaxValue},
55 new object[] {
int.MinValue.ToString(), typeof (
int),
false,
int.MinValue},
56 new object[] {((long)
int.MaxValue + 1).ToString(), typeof (
int),
true,
null},
57 new object[] {((long)
int.MinValue - 1).ToString(), typeof (
int),
true,
null},
59 new object[] {
"1", typeof (uint),
false, (uint) 1},
62 new object[] {uint.MaxValue.ToString(), typeof (uint),
false, uint.MaxValue},
63 new object[] {uint.MinValue.ToString(), typeof (uint),
false, uint.MinValue},
64 new object[] {((long) uint.MaxValue + 1).ToString(), typeof (uint),
true,
null},
65 new object[] {((long) uint.MinValue - 1).ToString(), typeof (uint),
true,
null},
67 new object[] {
"true", typeof (
bool),
false,
true},
68 new object[] {
"True", typeof (
bool),
false,
true},
69 new object[] {
"TRUE", typeof (
bool),
false,
true},
70 new object[] {
"false", typeof (
bool),
false,
false},
71 new object[] {
"False", typeof (
bool),
false,
false},
72 new object[] {
"FALSE", typeof (
bool),
false,
false},
73 new object[] {
"abcd", typeof (
bool),
true,
null},
74 new object[] {
"0", typeof (
bool),
true,
null},
75 new object[] {
"1", typeof (
bool),
true,
null},
77 new object[] {
"1.0", typeof (
float),
false, 1.0f},
78 new object[] {
"0.0", typeof (
float),
false, 0.0f},
79 new object[] {
"-1.0", typeof (
float),
false, -1.0f},
80 new object[] {
"abcd", typeof (
float),
true,
null},
82 new object[] {
"1.0", typeof (
double),
false, 1.0},
83 new object[] {
"0.0", typeof (
double),
false, 0.0},
84 new object[] {
"-1.0", typeof (
double),
false, -1.0},
85 new object[] {
"abcd", typeof (
double),
true,
null},
87 new object[] {
"1.0", typeof (decimal),
false, 1.0m},
88 new object[] {
"0.0", typeof (decimal),
false, 0.0m},
89 new object[] {
"-1.0", typeof (decimal),
false, -1.0m},
90 new object[] {
"-1.123456", typeof (decimal),
false, -1.123456m},
91 new object[] {
"abcd", typeof (decimal),
true,
null},
93 new object[] {
"", typeof (
string),
false,
""},
94 new object[] {
"abcd", typeof (
string),
false,
"abcd"},
101 new object[] {((int)
TestEnum.ValueB + 1).ToString(), typeof (
TestEnum),
true,
null},
102 new object[] {((int)
TestEnum.ValueA - 1).ToString(), typeof (
TestEnum),
true,
null},
118 new object[] {
"false", typeof (
int),
true, 0},
119 new object[] {
"true", typeof (
int),
true, 0}
132 result.
MatchNothing().Should().BeTrue(
"should fail parsing");
136 result.
MatchJust(out
object matchedValue).Should().BeTrue(
"should parse successfully");
137 Assert.Equal(matchedValue, expectedResult);