Esempio n. 1
0
        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 = NFX.Parsing.NaturalTextGenerator.GenerateAddressLine(),
                Address2 = (gdid.ID % 7) == 0 ? NFX.Parsing.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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void PutCheckerboardPattern2()
        {
            using (var pile = new DefaultPile())
            {
                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);
                }

                Assert.AreEqual(CNT, ipile.ObjectCount);

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

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

                Assert.AreEqual(CNT / 2, ipile.ObjectCount);

                for (ulong i = 0; i < CNT; i++)
                {
                    if (i % 2 == 0)
                    {
                        try
                        {
                            ipile.Get(ppp[i].Item1);
                            Assert.Fail("Object is deleted but its pointer doesn't throw exception!");
                        }
                        catch (PileAccessViolationException) {}
                    }
                    else
                    {
                        var ch = ipile.Get(ppp[i].Item1);
                        Assert.AreEqual(ch, ppp[i].Item2);
                    }
                }
            }
        }
Esempio n. 4
0
        public void PutWOStart()
        {
            using (var pile = new DefaultPile())
            {
                var ipile = pile as IPile;

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

                var pp = ipile.Put(row);

                Assert.IsFalse(pp.Valid);

                Assert.AreEqual(0, ipile.ObjectCount);
                Assert.AreEqual(0, ipile.AllocatedMemoryBytes);
                Assert.AreEqual(0, ipile.UtilizedBytes);
                Assert.AreEqual(0, ipile.OverheadBytes);
                Assert.AreEqual(0, ipile.SegmentCount);
            }
        }
Esempio n. 5
0
        public void Purge()
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();
                var ipile = pile as IPile;

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

                var pp = ipile.Put(rowIn);

                ipile.Purge();

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

                var rowOut = ipile.Get(pp);
            }
        }
Esempio n. 6
0
        public void DeleteExisting()
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();
                var ipile = pile as IPile;

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

                var pp = ipile.Put(rowIn);

                ipile.Delete(pp);

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

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