コード例 #1
0
        //[ExpectedException(typeof(ArgumentException))]
        public virtual void GuidToByteArr()
        {
            /*Guid guid = new Guid("df793523-e09a-49d9-bf43-54ad35ffde4a");
             * Guid? guidd = new Guid("df793523-e09a-49d9-bf43-54ad35ffde41");
             * //Guid? guidn = null;
             *
             * byte[] b;
             * b = guid.ToByteArray();
             * for (int i = 0; i < b.Length; i++)
             * {
             *  Console.Write(b[i]+",");
             * }//35,53,121,223,154,224,217,73,191,67,84,173,53,255,222,74
             * Console.WriteLine("------");
             * b = guidd.Value.ToByteArray();
             * for (int i = 0; i < b.Length; i++)
             * {
             *  Console.Write(b[i]+",");
             * }//35,53,121,223,154,224,217,73,191,67,84,173,53,255,222,65
             * //b = guidn.Value.ToByteArray();
             * //Console.WriteLine(b);*/
            Guid g  = new Guid("df793523-e09a-49d9-bf43-54ad35ffde4a");
            Guid gg = new Guid("df793523-e09a-49d9-bf43-54ad35ffde41");

            byte[] s  = { 35, 53, 121, 223, 154, 224, 217, 73, 191, 67, 84, 173, 53, 255, 222, 74 };
            byte[] ss = { 35, 53, 121, 223, 154, 224, 217, 73, 191, 67, 84, 173, 53, 255, 222, 65 };

            s.AreEqual(PrimitiveMapper.Map <Guid, byte[]>(g));
            ss.AreEqual(PrimitiveMapper.Map <Guid, byte[]>(gg));

            s.AreEqual(PrimitiveMapper.Map <Guid?, byte[]>(g));
            ss.AreEqual(PrimitiveMapper.Map <Guid?, byte[]>(gg));
            PrimitiveMapper.Map <Guid?, byte[]>(null).AreEqual(null);
        }
コード例 #2
0
ファイル: ByteConvertTest.cs プロジェクト: saber-wang/elinq
        public virtual void Execute(string fieldName, object value, Expression <Func <NullableTypeInfo, bool> > filter)
        {
            var identityFieldValue = "zxmlx";
            var expected           = new NullableTypeInfo {
                String = identityFieldValue
            };
            var field = typeof(NullableTypeInfo).GetField(fieldName);

            Assert.IsNotNull(field);
            field
            .SetValue(expected, PrimitiveMapper.Map(value, field.FieldType));

            //if (base.Db.Dialect is NLite.Data.Dialect.SQLiteDialect)
            //{
            //    base.Db.Connection.BeginTransaction();
            //}
            Table.Delete(p => true);
            Table.Insert(expected);

            var actual = Table
                         .Where(p => p.String == expected.String)
                         .Where(filter)
                         .Select(p => new { Id = p.Id, p.String })
                         .FirstOrDefault();

            Assert.IsNotNull(actual);

            Table.Delete(p => true);
        }
コード例 #3
0
        public virtual void ByteToGuid()
        {
            byte[] i  = { 35, 53, 121, 223, 154, 224, 217, 73, 191, 67, 84, 173, 53, 255, 222, 74 };
            byte[] j  = { 35, 53, 121, 223, 154, 224, 217, 73, 191, 67, 84, 173, 53, 255, 222, 65 };
            Guid   g  = new Guid("df793523-e09a-49d9-bf43-54ad35ffde4a");
            Guid   gg = new Guid("df793523-e09a-49d9-bf43-54ad35ffde41");

            Assert.IsTrue(PrimitiveMapper.Map <byte[], Guid>(i) == g);
            Assert.IsTrue(PrimitiveMapper.Map <byte[], Guid>(j) == gg);

            //Assert.IsTrue(PrimitiveMapper.Map<byte[], Guid?>(i) == g);
            //Assert.IsTrue(PrimitiveMapper.Map<byte[], Guid?>(j) == gg);
        }
コード例 #4
0
        public virtual void StringToGuid()
        {
            string i = "df793523-e09a-49d9-bf43-54ad35ffde4a";
            string j = "df793523-e09a-49d9-bf43-54ad35ffde41";

            Guid g  = new Guid("df793523-e09a-49d9-bf43-54ad35ffde4a");
            Guid gg = new Guid("df793523-e09a-49d9-bf43-54ad35ffde41");

            Assert.IsTrue(PrimitiveMapper.Map <string, Guid>(i) == g);
            Assert.IsTrue(PrimitiveMapper.Map <string, Guid>(j) == gg);

            Assert.IsTrue(PrimitiveMapper.Map <string, Guid?>(i) == g);
            Assert.IsTrue(PrimitiveMapper.Map <string, Guid?>(j) == gg);
        }
コード例 #5
0
        public virtual void StringToEnum()
        {
            DayOfWeek i = DayOfWeek.Friday;
            DayOfWeek j = DayOfWeek.Monday;
            DayOfWeek k = DayOfWeek.Sunday;

            Assert.IsTrue(PrimitiveMapper.Map <string, DayOfWeek>("Friday") == i);
            Assert.IsTrue(PrimitiveMapper.Map <string, DayOfWeek>("Monday") == j);
            Assert.IsTrue(PrimitiveMapper.Map <string, DayOfWeek>("Sunday") == k);

            Assert.IsTrue(PrimitiveMapper.Map <string, DayOfWeek?>("Friday") == i);
            Assert.IsTrue(PrimitiveMapper.Map <string, DayOfWeek?>("Monday") == j);
            Assert.IsTrue(PrimitiveMapper.Map <string, DayOfWeek?>("Sunday") == k);
        }
コード例 #6
0
        public virtual void GuidToString()
        {
            Guid   g  = new Guid("df793523-e09a-49d9-bf43-54ad35ffde4a");
            Guid   gg = new Guid("df793523-e09a-49d9-bf43-54ad35ffde41");
            string s  = "df793523-e09a-49d9-bf43-54ad35ffde4a";
            string ss = "df793523-e09a-49d9-bf43-54ad35ffde41";

            Console.WriteLine(g);//df793523-e09a-49d9-bf43-54ad35ffde4a
            Assert.AreEqual(PrimitiveMapper.Map <Guid, string>(g), s);
            Assert.IsTrue(PrimitiveMapper.Map <Guid, string>(gg) == ss);

            Assert.IsTrue(PrimitiveMapper.Map <Guid?, string>(g) == s);
            Assert.IsTrue(PrimitiveMapper.Map <Guid?, string>(gg) == ss);
            Assert.IsNull(PrimitiveMapper.Map <Guid?, string>(null));
        }
コード例 #7
0
        public virtual void ToSString()
        {
            string i = "Friday";
            string k = "Monday";
            string j = "Sunday";

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, string>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, string>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, string>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, string>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, string>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, string>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, string>(null));
        }
コード例 #8
0
        public virtual void ToUInt32()
        {
            /*DayOfWeek d;
             * d = DayOfWeek.Saturday;
             * DayOfWeek? dd;
             * DayOfWeek? ddy = DayOfWeek.Saturday;
             * dd = null;
             * uint s;
             * uint? ss;
             *
             * s = Convert.ToUInt32(d);
             * Assert.IsTrue(s == 6);
             * s = Convert.ToUInt32(dd);
             * Assert.IsTrue(s == 0);
             * s = Convert.ToUInt32(ddy);
             * Assert.IsTrue(s == 6);
             * ss = Convert.ToUInt32(d);
             * Assert.IsTrue(ss == 6);
             * ss = Convert.ToUInt32(dd);
             * Assert.IsTrue(ss == 0);
             * ss = Convert.ToUInt32(ddy);
             * Assert.IsTrue(ss == 6);*/
            uint i = 5;
            uint k = 1;
            uint j = 0;

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, uint>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, uint>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, uint>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, uint>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, uint>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, uint>(DayOfWeek.Sunday) == j);
            Assert.IsNotNull(PrimitiveMapper.Map <DayOfWeek?, uint>(null));

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, uint?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, uint?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, uint?>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, uint?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, uint?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, uint?>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, uint?>(null));
        }
コード例 #9
0
        public virtual void Int16ToEnum()
        {
            /*short i = 4;
             * short? ii = 4;
             * //int? iiy =null;
             * DayOfWeek d;
             * DayOfWeek? dd;
             *
             * d = (DayOfWeek)i;
             * Assert.IsTrue(d == DayOfWeek.Thursday);
             * d = (DayOfWeek)ii;
             * Assert.IsTrue(d == DayOfWeek.Thursday);
             * //d = (DayOfWeek)iiy;
             * //Assert.IsNull(d);
             *
             * dd = (DayOfWeek)i;
             * Assert.IsTrue(dd == DayOfWeek.Thursday);
             * dd = (DayOfWeek)ii;
             * Assert.IsTrue(dd == DayOfWeek.Thursday);
             * //dd = (DayOfWeek)iiy;
             * //Assert.IsNull(dd);*/
            short i = 6;
            short j = 1;
            short k = 0;

            Assert.IsTrue(PrimitiveMapper.Map <short, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <short, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <short, DayOfWeek>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <short?, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <short?, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <short?, DayOfWeek>(k) == DayOfWeek.Sunday);
            Assert.IsNotNull(PrimitiveMapper.Map <short?, DayOfWeek>(null));

            Assert.IsTrue(PrimitiveMapper.Map <short, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <short, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <short, DayOfWeek?>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <short?, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <short?, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <short?, DayOfWeek?>(k) == DayOfWeek.Sunday);
            Assert.IsNull(PrimitiveMapper.Map <short?, DayOfWeek?>(null));
        }
コード例 #10
0
        public virtual void UInt64ToEnum()
        {
            ulong i = 6;
            ulong j = 1;
            ulong k = 0;

            Assert.IsTrue(PrimitiveMapper.Map <ulong, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong, DayOfWeek>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <ulong?, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong?, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong?, DayOfWeek>(k) == DayOfWeek.Sunday);
            Assert.IsNotNull(PrimitiveMapper.Map <ulong?, DayOfWeek>(null));

            Assert.IsTrue(PrimitiveMapper.Map <ulong, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong, DayOfWeek?>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <ulong?, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong?, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <ulong?, DayOfWeek?>(k) == DayOfWeek.Sunday);
            Assert.IsNull(PrimitiveMapper.Map <ulong?, DayOfWeek?>(null));
        }
コード例 #11
0
        public virtual void ToInt32()
        {
            int i = 5;
            int k = 1;
            int j = 0;

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, Int32>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, Int32>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, Int32>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, Int32>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, Int32>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, Int32>(DayOfWeek.Sunday) == j);
            Assert.IsNotNull(PrimitiveMapper.Map <DayOfWeek?, Int32>(null));

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, Int32?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, Int32?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, Int32?>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, Int32?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, Int32?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, Int32?>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, Int32?>(null));
        }
コード例 #12
0
        public virtual void SByteToEnum()
        {
            sbyte i = 6;
            sbyte j = 1;
            sbyte k = 0;

            Assert.IsTrue(PrimitiveMapper.Map <sbyte, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte, DayOfWeek>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <sbyte?, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte?, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte?, DayOfWeek>(k) == DayOfWeek.Sunday);
            Assert.IsNotNull(PrimitiveMapper.Map <sbyte?, DayOfWeek>(null));

            Assert.IsTrue(PrimitiveMapper.Map <sbyte, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte, DayOfWeek?>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <sbyte?, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte?, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <sbyte?, DayOfWeek?>(k) == DayOfWeek.Sunday);
            Assert.IsNull(PrimitiveMapper.Map <sbyte?, DayOfWeek?>(null));
        }
コード例 #13
0
        //[ExpectedException(typeof(ArgumentException))]
        public virtual void DecimalToEnum()
        {
            decimal i = 6;
            decimal j = 1;
            decimal k = 0;

            Assert.IsTrue(PrimitiveMapper.Map <decimal, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal, DayOfWeek>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <decimal?, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal?, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal?, DayOfWeek>(k) == DayOfWeek.Sunday);
            Assert.IsNotNull(PrimitiveMapper.Map <decimal?, DayOfWeek>(null));

            Assert.IsTrue(PrimitiveMapper.Map <decimal, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal, DayOfWeek?>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <decimal?, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal?, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <decimal?, DayOfWeek?>(k) == DayOfWeek.Sunday);
            Assert.IsNull(PrimitiveMapper.Map <decimal?, DayOfWeek?>(null));
        }
コード例 #14
0
        public virtual void ToDouble()
        {
            double i = 5;
            double k = 1;
            double j = 0;

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, double>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, double>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, double>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, double>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, double>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, double>(DayOfWeek.Sunday) == j);
            Assert.IsNotNull(PrimitiveMapper.Map <DayOfWeek?, double>(null));

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, double?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, double?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, double?>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, double?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, double?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, double?>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, double?>(null));
        }
コード例 #15
0
        public virtual void UInt32ToEnum()
        {
            uint i = 6;
            uint j = 1;
            uint k = 0;

            Assert.IsTrue(PrimitiveMapper.Map <uint, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <uint, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <uint, DayOfWeek>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <uint?, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <uint?, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <uint?, DayOfWeek>(k) == DayOfWeek.Sunday);
            Assert.IsNotNull(PrimitiveMapper.Map <uint?, DayOfWeek>(null));

            Assert.IsTrue(PrimitiveMapper.Map <uint, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <uint, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <uint, DayOfWeek?>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <uint?, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <uint?, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <uint?, DayOfWeek?>(k) == DayOfWeek.Sunday);
            Assert.IsNull(PrimitiveMapper.Map <uint?, DayOfWeek?>(null));
        }
コード例 #16
0
        public virtual void ToUInt16()
        {
            ushort i = 5;
            ushort k = 1;
            ushort j = 0;

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ushort>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ushort>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ushort>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ushort>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ushort>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ushort>(DayOfWeek.Sunday) == j);
            Assert.IsNotNull(PrimitiveMapper.Map <DayOfWeek?, ushort>(null));

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ushort?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ushort?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ushort?>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ushort?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ushort?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ushort?>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, ushort?>(null));
        }
コード例 #17
0
        public virtual void ToSByte()
        {
            sbyte i = 5;
            sbyte k = 1;
            sbyte j = 0;

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, sbyte>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, sbyte>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, sbyte>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, sbyte>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, sbyte>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, sbyte>(DayOfWeek.Sunday) == j);
            Assert.IsNotNull(PrimitiveMapper.Map <DayOfWeek?, sbyte>(null));

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, sbyte?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, sbyte?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, sbyte?>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, sbyte?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, sbyte?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, sbyte?>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, sbyte?>(null));
        }
コード例 #18
0
        public virtual void ToDecimal()
        {
            decimal i = 5M;
            decimal k = 1M;
            decimal j = 0M;

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, decimal>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, decimal>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, decimal>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, decimal>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, decimal>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, decimal>(DayOfWeek.Sunday) == j);
            Assert.IsNotNull(PrimitiveMapper.Map <DayOfWeek?, decimal>(null));

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, decimal?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, decimal?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, decimal?>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, decimal?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, decimal?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, decimal?>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, decimal?>(null));
        }
コード例 #19
0
        public virtual void DoubleToEnum()
        {
            double i = 6;
            double j = 1;
            double k = 0;

            Assert.IsTrue(PrimitiveMapper.Map <double, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <double, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <double, DayOfWeek>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <double?, DayOfWeek>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <double?, DayOfWeek>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <double?, DayOfWeek>(k) == DayOfWeek.Sunday);
            Assert.IsNotNull(PrimitiveMapper.Map <double?, DayOfWeek>(null));

            Assert.IsTrue(PrimitiveMapper.Map <double, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <double, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <double, DayOfWeek?>(k) == DayOfWeek.Sunday);

            Assert.IsTrue(PrimitiveMapper.Map <double?, DayOfWeek?>(i) == DayOfWeek.Saturday);
            Assert.IsTrue(PrimitiveMapper.Map <double?, DayOfWeek?>(j) == DayOfWeek.Monday);
            Assert.IsTrue(PrimitiveMapper.Map <double?, DayOfWeek?>(k) == DayOfWeek.Sunday);
            Assert.IsNull(PrimitiveMapper.Map <double?, DayOfWeek?>(null));
        }
コード例 #20
0
        public virtual void ToUInt64()
        {
            ulong i = 5;
            ulong k = 1;
            ulong j = 0;

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ulong>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ulong>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ulong>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ulong>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ulong>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ulong>(DayOfWeek.Sunday) == j);
            Assert.IsNotNull(PrimitiveMapper.Map <DayOfWeek?, ulong>(null));

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ulong?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ulong?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek, ulong?>(DayOfWeek.Sunday) == j);

            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ulong?>(DayOfWeek.Friday) == i);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ulong?>(DayOfWeek.Monday) == k);
            Assert.IsTrue(PrimitiveMapper.Map <DayOfWeek?, ulong?>(DayOfWeek.Sunday) == j);
            Assert.IsNull(PrimitiveMapper.Map <DayOfWeek?, ulong?>(null));
        }