예제 #1
0
        public void EnumValue()
        {
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2?> .From((int?)1));
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2> .From(Enum2.Value1));
            Assert.AreEqual(Enum2.Value2, ConvertTo <Enum2> .From(Enum3.Value2));
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2> .From(1));
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2> .From((int?)1));
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2?> .From(1));
            Assert.AreEqual(Enum3.Value1, ConvertTo <Enum3> .From(1.0));
            Assert.AreEqual(Enum3.Value1, ConvertTo <Enum3?> .From(1.0));
            Assert.AreEqual(Enum3.Value1, ConvertTo <Enum3?> .From((double?)1.0));
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2> .From("1"));
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2> .From("+1"));

            Assert.AreEqual("Value1", ConvertTo <string> .From(Enum2.Value1));
            Assert.AreEqual(Enum2.Value1, ConvertTo <Enum2> .From("Value1"));
            Assert.AreEqual(Enum2.Value2, ConvertTo <Enum2> .From("value2"));
        }
예제 #2
0
 public void ConvertTo()
 {
     Assert.AreEqual(10, ConvertTo <TestData1> .From(10).Value);
     Assert.AreEqual(10, ConvertTo <TestData2> .From(10).Value);
 }
예제 #3
0
 public void ConvertFromNullableEnum2()
 {
     Assert.AreEqual(10, ConvertTo <int> .From((Enum15?)Enum15.AA));
     Assert.AreEqual(0, ConvertTo <int> .From((Enum15?)null));
     Assert.AreEqual(null, ConvertTo <int?> .From((Enum15?)null));
 }
예제 #4
0
 public void ToObject()
 {
     Assert.AreEqual(1, ConvertTo <object> .From(1));
 }
예제 #5
0
 public void ConvertToEnum11()
 {
     Assert.AreEqual(Enum11.Value1, ConvertTo <Enum11> .From(Enum10.Value2));
     Assert.AreEqual(Enum11.Value2, ConvertTo <Enum11> .From(Enum10.Value1));
     Assert.AreEqual(Enum11.Value3, ConvertTo <Enum11> .From(Enum10.Value3));
 }
예제 #6
0
 public void ConvertFromEnum5()
 {
     Assert.AreEqual(10, ConvertTo <int> .From(Enum9.Value1));
     Assert.AreEqual(2, ConvertTo <int> .From(Enum9.Value2));
 }
예제 #7
0
 public void ConvertToEnum10()
 {
     Assert.AreEqual(Enum9.Value1, ConvertTo <Enum9> .From(1));
     Assert.AreEqual(Enum9.Value1, ConvertTo <Enum9> .From(10));
     Assert.AreEqual(Enum9.Value2, ConvertTo <Enum9> .From(2));
 }
예제 #8
0
 public void ConvertToEnum9()
 {
     Assert.AreEqual(Enum7.Value2, ConvertTo <Enum7> .From(Enum8.Value1));
 }
예제 #9
0
 public void ConvertToEnum7()
 {
     Assert.AreEqual(Enum5.Value2, ConvertTo <Enum5> .From((Enum6?)Enum6.Value1));
 }
예제 #10
0
 public void ConvertToEnum2()
 {
     Assert.AreEqual(Enum6.Value2, ConvertTo <Enum6> .From(Enum5.Value1));
 }
예제 #11
0
 public void ConvertToEnum1()
 {
     Assert.AreEqual(Enum4.Value2, ConvertTo <Enum4> .From(25));
 }
예제 #12
0
 public void FromValue()
 {
     Assert.AreEqual(10, ConvertTo <int> .From(new System.Data.SqlTypes.SqlInt32(10)));
 }
예제 #13
0
 public void ParseChar()
 {
     Assert.AreEqual('\0', ConvertTo <char> .From((string?)null));
     Assert.AreEqual('\0', ConvertTo <char> .From(""));
 }
예제 #14
0
 public void Parse()
 {
     Assert.AreEqual(10, ConvertTo <int> .From("10"));
     Assert.AreEqual(new DateTime(2012, 1, 1), ConvertTo <DateTime> .From("2012-1-1"));
 }
예제 #15
0
 public void FromValue()
 {
     Assert.AreEqual(10, ConvertTo <int> .From(new SqlInt32(10)));
 }