Beispiel #1
0
        public void testDecimal()
        {
            TMoney m = new TMoney();

            m.MyMoney    = 36.83m;
            m.DecimalNum = 777.1234m;

            m.DubleNum  = 988.123456;
            m.SingleNum = 999.12f;
            m.insert();

            TMoney mb = new TMoney();

            mb.MyMoney    = 99.1268m;   // money类型可以最多存储4位数
            mb.DecimalNum = 777.12345m; // TMoney批注里自定义了5位小数

            mb.DubleNum  = 988.1234567899;
            mb.SingleNum = 999.128f; // mysql float默认3位
            mb.insert();

            List <TMoney> list = TMoney.findAll();

            Assert.AreEqual(2, list.Count);

            TMoney m1 = list[0];

            Assert.AreEqual(m1.MyMoney, m.MyMoney);
            Assert.AreEqual(m1.DecimalNum, m.DecimalNum);
            Assert.AreEqual(m1.DubleNum, m.DubleNum);
            Assert.AreEqual(m1.SingleNum, m.SingleNum);

            TMoney m2 = list[1];

            Assert.AreEqual(m2.MyMoney, mb.MyMoney);
            Assert.AreEqual(m2.DecimalNum, mb.DecimalNum);
            Assert.AreEqual(m2.DubleNum, mb.DubleNum);
            Assert.AreEqual(m2.SingleNum, mb.SingleNum);

            foreach (TMoney tm in list)
            {
                Console.WriteLine(tm.MyMoney + "\t" + tm.SingleNum + "\t" + tm.DubleNum + "\t" + tm.DecimalNum);
            }
        }
Beispiel #2
0
        public void testDecimal()
        {
            TMoney m = new TMoney();
            m.MyMoney = 36.83m;
            m.DecimalNum = 777.1234m;

            m.DubleNum = 988.123456;
            m.SingleNum = 999.12f;
            m.insert();

            TMoney mb = new TMoney();
            mb.MyMoney = 99.1268m; // money���Ϳ������洢4λ��
            mb.DecimalNum = 777.12345m; // TMoney��ע���Զ�����5λС��

            mb.DubleNum = 988.1234567899;
            mb.SingleNum = 999.128f; // mysql floatĬ��3λ
            mb.insert();

            List<TMoney> list = TMoney.findAll();

            Assert.AreEqual( 2, list.Count );

            TMoney m1 = list[0];
            Assert.AreEqual( m1.MyMoney, m.MyMoney );
            Assert.AreEqual( m1.DecimalNum, m.DecimalNum );
            Assert.AreEqual( m1.DubleNum, m.DubleNum );
            Assert.AreEqual( m1.SingleNum, m.SingleNum );

            TMoney m2 = list[1];
            Assert.AreEqual( m2.MyMoney, mb.MyMoney );
            Assert.AreEqual( m2.DecimalNum, mb.DecimalNum );
            Assert.AreEqual( m2.DubleNum, mb.DubleNum );
            Assert.AreEqual( m2.SingleNum, mb.SingleNum );

            foreach (TMoney tm in list) {
                Console.WriteLine( tm.MyMoney + "\t" + tm.SingleNum + "\t" + tm.DubleNum + "\t" + tm.DecimalNum );
            }
        }