/// <summary>
 /// Create a trasnaction list with random transactions
 /// </summary>
 /// <param name="r"></param>
 /// <param name="txCount"></param>
 /// <returns></returns>
 public static TransactionList NextTransactionList(this Random r, int txCount)
 {
     TransactionList tl = new TransactionList();
     for (int i = 0; i < txCount; i++)
     {
         Transaction tx = new Transaction() { Date = r.NextDate() };
         int index = r.Next(tl.Count + 1);
         tl.Insert(index, tx);
     }
     return tl;
 }
Пример #2
0
 void AssertAtIndex(TransactionList tl, int index, Transaction tx)
 {
     Assert.AreEqual(index, tl.IndexOf(tx), "Transaction at wrong index: " + tx.Date);
 }
Пример #3
0
        Transaction newTx(String dateStr, String comment = "")
        {
            DateTime date = DateTime.ParseExact(dateStr, "yyyy-MM-dd", CultureInfo.InvariantCulture);
            Transaction tx = new Transaction() { Date = date, Comment = comment };

            return tx;
        }
Пример #4
0
        public void InsertRandom()
        {
            Console.WriteLine("Seed: " + RandomSeed);

            Random r = new Random(RandomSeed);

            TransactionList tl = new TransactionList();
            for (int i = 0; i < RandomRunCount; i++)
            {
                Transaction tx = new Transaction() { Date = r.NextDate() };
                int index = r.Next(tl.Count + 1);
                tl.Insert(index, tx);

                //Console.WriteLine(String.Format("{0}. {1:yyyy-MM-dd} {2}->?", i, tx.Date, index));
                AssertInOrder(tl);
            }
            Console.WriteLine("<end>");
            AssertInOrder(tl);
        }