コード例 #1
0
ファイル: TRow.cs プロジェクト: wangchengqun/azos
        public static CheckoutRow MakeFake(GDID gdid)
        {
            var ch = new CheckoutRow()
            {
                ID          = gdid,
                Customer    = PersonRow.MakeFake(gdid),
                FileName    = "myface_" + gdid.ID.ToString(),
                Date        = DateTime.Now,
                StartOffset = gdid.ID * 20,
                G_Block     = gdid,

                Address1 = Text.NaturalTextGenerator.GenerateAddressLine(),
                Address2 = (gdid.ID % 7) == 0 ? Text.NaturalTextGenerator.GenerateAddressLine() : null
            };

            var chCnt = (int)(gdid.ID % 10);

            ch.Charges = new ChargeRow[chCnt];

            for (int i = 0; i < chCnt; i++)
            {
                ch.Charges[i] = ChargeRow.MakeFake(gdid);
            }

            return(ch);
        }
コード例 #2
0
ファイル: TRow.cs プロジェクト: wangchengqun/azos
        public static ChargeRow MakeFake(GDID gdid)
        {
            var c = new ChargeRow()
            {
                Amount    = new Amount("usd", gdid.ID % 1897),
                Qty       = (int)(gdid.ID % 29),
                G_Product = gdid,
                Notes     = new String('n', (int)(gdid.ID % 137))
            };

            return(c);
        }
コード例 #3
0
ファイル: MMFPileTest.cs プロジェクト: wangchengqun/azos
        public void PutCheckerboardPattern2()
        {
            using (var pile = MakeMMFPile())
            {
                pile.Start();
                var ipile = pile as IPile;

                const ulong CNT = 100;

                var ppp = new Tuple <PilePointer, ChargeRow> [CNT];

                for (ulong i = 0; i < CNT; i++)
                {
                    var ch = ChargeRow.MakeFake(new GDID(0, i));
                    ppp[i] = new Tuple <PilePointer, ChargeRow>(ipile.Put(ch), ch);
                }

                Aver.AreEqual(CNT, (ulong)ipile.ObjectCount);

                for (ulong i = 0; i < CNT; i++)
                {
                    var ch = ipile.Get(ppp[i].Item1);
                    Aver.AreObjectsEqual(ch, ppp[i].Item2);
                }

                for (ulong i = 0; i < CNT; i += 2)
                {
                    ipile.Delete(ppp[i].Item1);
                }

                Aver.AreEqual(CNT / 2, (ulong)ipile.ObjectCount);

                for (ulong i = 0; i < CNT; i++)
                {
                    if (i % 2 == 0)
                    {
                        try
                        {
                            ipile.Get(ppp[i].Item1);
                            Aver.Fail("Object is deleted but its pointer doesn't throw exception!");
                        }
                        catch (PileAccessViolationException) {}
                    }
                    else
                    {
                        var ch = ipile.Get(ppp[i].Item1);
                        Aver.AreObjectsEqual(ch, ppp[i].Item2);
                    }
                }
            }
        }
コード例 #4
0
ファイル: MMFPileTest.cs プロジェクト: wangchengqun/azos
        public void PutWOStart()
        {
            using (var pile = MakeMMFPile())
            {
                var ipile = pile as IPile;

                var row = ChargeRow.MakeFake(new GDID(0, 1));

                var pp = ipile.Put(row);

                Aver.IsFalse(pp.Valid);

                Aver.AreEqual(0, ipile.ObjectCount);
                Aver.AreEqual(0, ipile.AllocatedMemoryBytes);
                Aver.AreEqual(0, ipile.UtilizedBytes);
                Aver.AreEqual(0, ipile.OverheadBytes);
                Aver.AreEqual(0, ipile.SegmentCount);
            }
        }
コード例 #5
0
ファイル: MMFPileTest.cs プロジェクト: wangchengqun/azos
        public void Purge()
        {
            using (var pile = MakeMMFPile())
            {
                pile.Start();
                var ipile = pile as IPile;

                var rowIn = ChargeRow.MakeFake(new GDID(0, 1));

                var pp = ipile.Put(rowIn);

                ipile.Purge();

                Aver.AreEqual(0, ipile.ObjectCount);
                Aver.AreEqual(0, ipile.SegmentCount);

                var rowOut = ipile.Get(pp);
            }
        }
コード例 #6
0
        public void Purge()
        {
            using (var pile = new DefaultPile(NOPApplication.Instance))
            {
                pile.Start();
                var ipile = pile as IPile;

                var rowIn = ChargeRow.MakeFake(new GDID(0, 1));

                var pp = ipile.Put(rowIn);

                ipile.Purge();

                Aver.AreEqual(0, ipile.ObjectCount);
                Aver.AreEqual(0, ipile.SegmentCount);

                var rowOut = ipile.Get(pp);
            }
        }
コード例 #7
0
ファイル: MMFPileTest.cs プロジェクト: wangchengqun/azos
        public void DeleteExisting()
        {
            using (var pile = MakeMMFPile())
            {
                pile.Start();
                var ipile = pile as IPile;

                var rowIn = ChargeRow.MakeFake(new GDID(0, 1));

                var pp = ipile.Put(rowIn);

                ipile.Delete(pp);

                Aver.AreEqual(0, ipile.ObjectCount);
                Aver.AreEqual(0, ipile.AllocatedMemoryBytes);
                Aver.AreEqual(0, ipile.UtilizedBytes);
                Aver.AreEqual(0, ipile.OverheadBytes);
                Aver.AreEqual(0, ipile.SegmentCount);

                var rowOut = ipile.Get(pp);
            }
        }