Esempio n. 1
0
        public static CheckoutRow MakeFake(GDID gdid)
        {
            var ch = new CheckoutRow()
            {
                ID          = 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 Charge[chCnt];

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

            return(ch);
        }
Esempio n. 2
0
        public void PutTwo()
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();

                var ipile = pile as IPile;

                var rowIn1 = Charge.MakeFake(new GDID(0, 1));
                var rowIn2 = Charge.MakeFake(new GDID(0, 2));

                var pp1 = ipile.Put(rowIn1);
                var pp2 = ipile.Put(rowIn2);

                Assert.AreEqual(2, ipile.ObjectCount);
                Assert.AreEqual(DefaultPile.SEG_SIZE_DFLT, ipile.AllocatedMemoryBytes);
                Assert.AreEqual(1, ipile.SegmentCount);

                var rowOut1 = pile.Get(pp1) as Charge;
                var rowOut2 = pile.Get(pp2) as Charge;

                Assert.AreEqual(rowIn1, rowOut1);
                Assert.AreEqual(rowIn2, rowOut2);
            }
        }
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, Charge> [CNT];

                for (ulong i = 0; i < CNT; i++)
                {
                    var ch = Charge.MakeFake(new GDID(0, i));
                    ppp[i] = new Tuple <PilePointer, Charge>(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 PutGetObject()
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();
                var ipile = pile as IPile;

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

                var pp = ipile.Put(rowIn);

                var rowOut = ipile.Get(pp) as Charge;

                Assert.AreEqual(rowIn, rowOut);
            }
        }
Esempio n. 5
0
        public void PutOne()
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();

                var ipile = pile as IPile;

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

                var pp = ipile.Put(row);

                Assert.AreEqual(1, ipile.ObjectCount);
                Assert.AreEqual(DefaultPile.SEG_SIZE_DFLT, ipile.AllocatedMemoryBytes);
                Assert.AreEqual(1, ipile.SegmentCount);
            }
        }
Esempio n. 6
0
        public void PutWOStart()
        {
            using (var pile = new DefaultPile())
            {
                var ipile = pile as IPile;

                var row = Charge.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. 7
0
        public void Purge()
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();
                var ipile = pile as IPile;

                var rowIn = Charge.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. 8
0
        public void DeleteExisting()
        {
            using (var pile = new DefaultPile())
            {
                pile.Start();
                var ipile = pile as IPile;

                var rowIn = Charge.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);
            }
        }