예제 #1
0
        public void DateTimeN_Current()
        {
            DateTime? dt    = DateTime.Now;
            DateTime? @null = null;
            BVector   d     = new BVector();

            d.Add(@null);
            d.Add1(false);
            d.Add(dt);


            Assert.AreEqual(@null, d.GetDateTimeN());
            Assert.AreEqual(false, d.Get1());
            Assert.AreEqual(dt, d.GetDateTimeN());
        }
예제 #2
0
        public void DateTimeN_MinMax()
        {
            DateTime? max   = DateTime.MaxValue;
            DateTime? min   = DateTime.MinValue;
            DateTime? @null = null;
            BVector   d     = new BVector();

            d.Add(max);
            d.Add1(false);
            d.Add(@null);
            d.Add1(false);
            d.Add(min);

            Assert.AreEqual(max, d.GetDateTimeN());
            Assert.AreEqual(false, d.Get1());
            Assert.AreEqual(@null, d.GetDateTimeN());
            Assert.AreEqual(false, d.Get1());
            Assert.AreEqual(min, d.GetDateTimeN());
        }
예제 #3
0
        /// <summary>
        /// Reads the next random value added by <see cref="WriteRandomValue(BVector)"/>
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public static object ReadNextRandomValue(BVector d)
        {
            bool nullable  = d.Get1();
            byte valueType = d.Get8();

            switch (valueType)
            {
            case 0:
                if (nullable)
                {
                    return(d.GetIntN());
                }
                return(d.GetInt());

            case 1:
                if (nullable)
                {
                    return(d.GetLongN());
                }
                return(d.GetLong());

            case 2:
                if (nullable)
                {
                    return(d.GetShortN());
                }
                return(d.GetShort());

            case 3:
                if (nullable)
                {
                    return(d.GetByteN());
                }
                return(d.GetByte());

            case 4:
                return(d.GetString());

            case 5:
                return(d.GetAscii());

            case 6:
                if (nullable)
                {
                    return(d.GetDateTimeN());
                }
                return(d.GetDateTime());

            case 7:
                if (nullable)
                {
                    return(d.GetDecimalN());
                }
                return(d.GetDecimal());

            case 8:
                if (nullable)
                {
                    return(d.GetDoubleN());
                }
                return(d.GetDouble());

            case 9:
                return(d.Get1());

            case 10:
                return(d.GetTimeSpan());

            case 11:
                return(d.GetByteArray());
            }
            return(null);
        }