Ejemplo n.º 1
0
 public void TestNullable()
 {
     {
         var t   = typeof(int?);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <int?>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(typeof(int), tt.NullableUnderlyingType);
         Assert.AreEqual(default(int?), tt.Default);
     }
     {
         var t   = typeof(StringComparison?);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <StringComparison?>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(typeof(StringComparison), tt.NullableUnderlyingType);
         Assert.AreEqual(default(StringComparison?), tt.Default);
     }
     {
         var t   = typeof(DateTime?);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <DateTime?>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(typeof(DateTime), tt.NullableUnderlyingType);
         Assert.AreEqual(default(DateTime?), tt.Default);
     }
 }
Ejemplo n.º 2
0
        public void TestInterface()
        {
            var t   = typeof(IDictionary);
            var tt  = TypeTraits.GetInfo(t);
            var tt2 = TypeTraits.Of <IDictionary>();

            Assert.AreEqual(tt, tt2);
            Assert.AreEqual(t, tt.Type);
            Assert.AreEqual(null, tt.NullableUnderlyingType);
            Assert.AreEqual(default(IDictionary), tt.Default);
        }
Ejemplo n.º 3
0
        public void TestStruct()
        {
            var t   = typeof(DateTime);
            var tt  = TypeTraits.GetInfo(t);
            var tt2 = TypeTraits.Of <DateTime>();

            Assert.AreEqual(tt, tt2);
            Assert.AreEqual(t, tt.Type);
            Assert.AreEqual(null, tt.NullableUnderlyingType);
            Assert.AreEqual(default(DateTime), tt.Default);
        }
Ejemplo n.º 4
0
        public void TestClass()
        {
            var t   = typeof(object);
            var tt  = TypeTraits.GetInfo(t);
            var tt2 = TypeTraits.Of <object>();

            Assert.AreEqual(tt, tt2);
            Assert.AreEqual(t, tt.Type);
            Assert.AreEqual(null, tt.NullableUnderlyingType);
            Assert.AreEqual(default(object), tt.Default);
        }
Ejemplo n.º 5
0
        public void TestEnum()
        {
            var t   = typeof(StringComparison);
            var tt  = TypeTraits.GetInfo(t);
            var tt2 = TypeTraits.Of <StringComparison>();

            Assert.AreEqual(tt, tt2);
            Assert.AreEqual(t, tt.Type);
            Assert.AreEqual(null, tt.NullableUnderlyingType);
            Assert.AreEqual(default(StringComparison), tt.Default);
        }
Ejemplo n.º 6
0
 public void TestPrimitive()
 {
     {
         var t   = typeof(int);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <int>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(default(int), tt.Default);
     }
     {
         var t   = typeof(byte);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <byte>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(default(byte), tt.Default);
     }
     {
         var t   = typeof(double);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <double>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(default(double), tt.Default);
     }
     {
         var t   = typeof(decimal);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <decimal>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(default(decimal), tt.Default);
     }
     {
         var t   = typeof(char);
         var tt  = TypeTraits.GetInfo(t);
         var tt2 = TypeTraits.Of <char>();
         Assert.AreEqual(tt, tt2);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(default(char), tt.Default);
     }
 }
Ejemplo n.º 7
0
 public void TestUnfinishedGeneric()
 {
     {
         var t  = typeof(IDictionary <,>);
         var tt = TypeTraits.GetInfo(t);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(null, tt.Default);
     }
     {
         var t  = typeof(Dictionary <,>);
         var tt = TypeTraits.GetInfo(t);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(null, tt.Default);
     }
     {
         var t  = typeof(KeyValuePair <,>);
         var tt = TypeTraits.GetInfo(t);
         Assert.AreEqual(t, tt.Type);
         Assert.AreEqual(null, tt.NullableUnderlyingType);
         Assert.AreEqual(null, tt.Default);
     }
 }