Beispiel #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);
        }
Beispiel #2
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);
                    }
                }
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
            }
        }