Generating Data for Testing
Now we can generate some test data. Don’t forget to update the database after the build. Let’s generate three cost items to test the Expense classes:
PersistenceManager pm = new PersistenceManager();
pm.BuildDatabase();
Employee e = new Employee();
e.FirstName = "John";
e.LastName = "Becker";
pm.MakePersistent(e);
Travel t = e.NewTravel();
t.Purpose = "NDO Workshop";
Receipt ev = new Receipt();
ev.ReceiptText = "Taxi";
ev.Sum = 30;
ev.Date = DateTime.Now.Date;
t.AddExpense(ev);
MileageAllowance ma = new MileageAllowance();
ma.MilesDriven = 200;
ma.Date = DateTime.Now.Date;
t.AddExpense(ma);
PerDiemAllowance pda = new PerDiemAllowance();
pda.Hours = (decimal)12.5;
pda.Date = DateTime.Now.Date;
t.AddExpense(pda);
pm.Save();