private void Window_Loaded(object sender, RoutedEventArgs e) { var VM = new CheckBookVM(); DataContext = VM; VM.Fill(); }
[TestMethod] //List the transaction between April 5th and 7th public void TransactionDatesBetween() { var ob = new CheckBookVM(); ob.Fill(); DateTime firstDate = new DateTime(2015, 05, 04); DateTime secondDate = new DateTime(2015, 07, 04); var numDate = ob.Transactions.Where(t => t.Date >= firstDate).Where(t => t.Date <= secondDate).Select(t => new { t.Account, t.Payee, t.Amount, t.Tag }); String[] acc = new String[] { "Checking", "Checking", "Credit", "Credit", "Credit", "Checking" }; String[] p = new String[] { "Moshe", "Tim", "Moshe", "Bracha", "Tim", "Bracha" }; String[] tags = new String[] { "Food", "Auto", "Food", "Food", "Auto", "Food" }; double[] amt = new double[] { 30, 130, 30, 30.5, 130, 30.5 }; for (int i = 0; i < numDate.Count(); i++) { Assert.AreEqual(acc[i], numDate.ElementAt(i).Account); Assert.AreEqual(p[i], numDate.ElementAt(i).Payee); Assert.AreEqual(amt[i], numDate.ElementAt(i).Amount); Assert.AreEqual(tags[i], numDate.ElementAt(i).Tag); } }
public void DateForEachAccount() { var ob = new CheckBookVM(); ob.Fill(); var d1 = new DateTime(2015, 04, 01); var d2 = new DateTime(2015, 04, 03); var d3 = new DateTime(2015, 04, 04); var d4 = new DateTime(2015, 04, 05); var d5 = new DateTime(2015, 04, 06); var d6 = new DateTime(2015, 04, 07); //Dates on which each account was used var d = ob.Transactions.Select(t => t.Date); //Testing Assert.AreEqual(d4, d.ElementAt(0)); Assert.AreEqual(d5, d.ElementAt(1)); Assert.AreEqual(d3, d.ElementAt(2)); Assert.AreEqual(d6, d.ElementAt(3)); Assert.AreEqual(d5, d.ElementAt(4)); Assert.AreEqual(d4, d.ElementAt(5)); Assert.AreEqual(d5, d.ElementAt(6)); Assert.AreEqual(d6, d.ElementAt(7)); Assert.AreEqual(d4, d.ElementAt(8)); Assert.AreEqual(d1, d.ElementAt(9)); Assert.AreEqual(d4, d.ElementAt(10)); Assert.AreEqual(d2, d.ElementAt(11)); }
[TestMethod] //List the dates on which each account was used public void DateForAccount() { var ob = new CheckBookVM(); ob.Fill(); var total = ob.Transactions.Count(); var totalCheckA = ob.Transactions.Where(t => t.Account == "Checking"); var totalCreditA = ob.Transactions.Where(t => t.Account == "Credit"); var checkcount = totalCheckA.Count(); var creditcount = totalCreditA.Count(); DateTime[] dateCheck = new DateTime[] { new DateTime(2015, 07, 04), new DateTime(2015, 05, 04), new DateTime(2015, 04, 04), new DateTime(2015, 03, 04), new DateTime(2015, 02, 04), new DateTime(2015, 06, 04) }; DateTime[] dateCredit = new DateTime[] { new DateTime(2015, 07, 04), new DateTime(2015, 06, 04), new DateTime(2015, 05, 04), new DateTime(2015, 04, 04), new DateTime(2015, 03, 04), new DateTime(2015, 02, 04) }; for (var i = 0; i < checkcount; i++) { Assert.AreEqual(dateCheck[i], totalCheckA.ElementAt(i).Date); } for (var i = 0; i < creditcount; i++) { Assert.AreEqual(dateCredit[i], totalCreditA.ElementAt(i).Date); } }
public void TransactionBtwApril5and7() { var ob = new CheckBookVM(); ob.Fill(); var query = ob.Transactions.Where(t => t.Date >= DateTime.Parse("4/5/2015")).Select(g => g.Date <= DateTime.Parse("4/7/2015")); Assert.AreEqual(6, query.Count()); }
public void AccountUsed() { var ob = new CheckBookVM(); ob.Fill(); var AccountDates = ob.Transactions.Select(d => new { d.Date, d.Account }).Count(); Assert.AreEqual(12, AccountDates); }
public void TransactionDates() { var ob = new CheckBookVM(); ob.Fill(); var TransactionCount = ob.Transactions.Where(d => d.Date >= DateTime.Parse("2015-4-5") && d.Date < DateTime.Parse("2015-4-8")).Count(); Assert.AreEqual(6, TransactionCount); }
public void CntOfTransBtn5and7th() { var obj = new CheckBookVM(); obj.Fill(); var dates = obj.Transactions.Where(t => t.Date.ToShortDateString() == "4/6/2015").Select(t => t.Date).ToArray().Length; Assert.AreEqual(3, dates); }
public void AverageFood() { var ob = new CheckBookVM(); ob.Fill(); var total = ob.Transactions.GroupBy(t => t.Tag).Select(g => new { g.Key, Avg = g.Average(t => t.Amount) }); Assert.AreEqual(32.625, total.First().Avg); Assert.AreEqual(75, total.Last().Avg); }
public void FillsUpProperly() { var ob = new CheckBookVM(); Assert.IsNull(ob.Transactions); ob.Fill(); Assert.AreEqual(12, ob.Transactions.Count); }
public void averagetransactionamount() { var ob = new CheckBookVM(); ob.Fill(); var avg = ob.Transactions.GroupBy(t => t.Tag).Select(g => new { g.Key, Avge = g.Average(t => t.Amount) }); Assert.AreEqual(32.625, avg.First().Avge); Assert.AreEqual(75, avg.Last().Avge); }
public void averageTransPerTag() { var ob = new CheckBookVM(); ob.Fill(); var average = ob.Transactions.GroupBy(tag => tag.Tag).Select(s => new { s.Key, avg = s.Average(tag => tag.Amount) }); Assert.AreEqual(32.625, average.First().avg); Assert.AreEqual(75, average.Last().avg); }
public void TrnsBtwn5n7() { var ob = new CheckBookVM(); ob.Fill(); var NoOfTrns = ob.Transactions.Where(t => t.Date >= DateTime.Parse("4/5/2015") && t.Date < DateTime.Parse("4/8/2015")).Count(); Assert.AreEqual(6, NoOfTrns); }
public void AccForMostAutoExps() { var obj = new CheckBookVM(); obj.Fill(); var max = obj.Transactions.GroupBy(t => t.Account).Select(g => new { g.Key, Account = g.Select(t => t.Tag == "Auto") }).Max(t => t.Key); Assert.AreEqual("Credit", max); }
public void CountofEqualsMoshe() { var ob = new CheckBookVM(); ob.Fill(); var count = ob.Transactions.Where(t => t.Payee == "Moshe").Count(); Assert.AreEqual(4, count); }
public void apriltransactions() { var ob = new CheckBookVM(); ob.Fill(); var date = DateTime.Parse("4/5/2015"); var date1 = DateTime.Parse("4/8/2015"); var trans = ob.Transactions.Where(t => (t.Date >= date.Date) & (t.Date < date1.Date)).Count(); Assert.AreEqual(6, trans); }
public void aprilTransactions() { var ob = new CheckBookVM(); ob.Fill(); var start_date = DateTime.Parse("4/5/2015"); var end_date = DateTime.Parse("4/8/2015"); var trans = ob.Transactions.Where(tag => (tag.Date >= start_date.Date) & (tag.Date < end_date.Date)).Count(); Assert.AreEqual(6, trans); }
public void MoneyOnAuto() { var ob = new CheckBookVM(); ob.Fill(); var Checking = ob.Transactions.Where(c => c.Tag == "Auto" && c.Account == "Checking").Sum(a => a.Amount); var Credittot = ob.Transactions.Where(h => h.Tag == "Auto" && h.Account == "Credit").Sum(a => a.Amount); Assert.IsTrue(Checking == Credittot); }
public void AvgTransaction() { var ob = new CheckBookVM(); ob.Fill(); var tot = ob.Transactions.GroupBy(s => s.Tag).Select(n => new { n.Key, avg = n.Average(s => s.Amount) }); Assert.AreEqual(32.625, tot.First().avg); Assert.AreEqual(75, tot.Last().avg); }
public void ListNumberOfTransactionsForEachAccount() { var ob = new CheckBookVM(); ob.Fill(); var checkingCount = ob.Transactions.Where(t => t.Account == "Checking" && t.Date.ToString("d") == DateTime.Parse("4/6/2015").ToString("d")).Count(); var creditCount = ob.Transactions.Where(t => t.Account == "Credit" && t.Date > DateTime.Parse("2015-4-5") && t.Date.ToString("d") == DateTime.Parse("4/6/2015").ToString("d")).Count(); Assert.AreEqual(1, checkingCount); Assert.AreEqual(1, creditCount); }
public void ListDates() { var ob = new CheckBookVM(); ob.Fill(); var CheckingDates = ob.Transactions.Where(t => t.Account == "Checking").Select(t => t.Date.Date.ToString("d")); var CreditDates = ob.Transactions.Where(t => t.Account == "Credit").Select(t => t.Date.Date.ToString("d")); Assert.AreEqual(DateTime.Now.AddDays(-1).Date.ToString("d"), CheckingDates.ElementAt(0)); Assert.AreEqual(DateTime.Now.AddDays(-1).Date.ToString("d"), CreditDates.ElementAt(0)); }
public void AccountOnAuto() { var ob = new CheckBookVM(); ob.Fill(); var count = ob.Transactions.Where(t => t.Tag == "Auto").Select(t => t.Account); var count1 = ob.Transactions.Select(g => g.Amount).Max(); Assert.AreEqual(130, count1); Assert.AreEqual("credit", count); }
public void dates() { var ob = new CheckBookVM(); ob.Fill(); var myDate = "4-4-2015"; var myDate1 = "4-7-2015"; var count = ob.Transactions.Where(t => t.Date > Convert.ToDateTime(myDate) & t.Date < Convert.ToDateTime(myDate1)).Count(); Assert.AreEqual(6, count); }
public void NumbersOfTransactionsOfEachAccount() { var ob = new CheckBookVM(); ob.Fill(); var Date = new DateTime(2015, 04, 06); var Date1 = ob.Transactions.Where(t => t.Date == Date).Select(t => t.Date).ToArray().Length; Assert.AreEqual(2, Date1); }
[TestMethod] //How much did you pay each payee for food? public void PayeeAmountFood() { var ob = new CheckBookVM(); ob.Fill(); var paymentF = ob.Transactions.Where(l => l.Tag == "Food").GroupBy(t => t.Payee).Select(g => new { Sum = g.Sum(t => t.Amount) }); Assert.AreEqual(130, paymentF.First().Sum); Assert.AreEqual(131, paymentF.Last().Sum); }
public void TotalForEachPayee() { var ob = new CheckBookVM(); ob.Fill(); var Sum = ob.Transactions.GroupBy(t => t.Payee).Select(g => new { g.Key, Sum = g.Sum(t => t.Amount) }).ToArray(); Assert.AreEqual(130, Sum[0].Sum); Assert.AreEqual(300, Sum[1].Sum); Assert.AreEqual(131, Sum[2].Sum); }
public void ListTransactions() { var ob = new CheckBookVM(); ob.Fill(); var transaction = ob.Transactions; var list = ob.Transactions.Where(t => t.Date.ToString("d") == DateTime.Parse("4/6/2015").ToString("d")); Assert.AreEqual(transaction.ElementAt(1), list.ElementAt(0)); Assert.AreEqual(transaction.ElementAt(7), list.ElementAt(1)); }
public void Group() { var ob = new CheckBookVM(); ob.Fill(); var total = ob.Transactions.GroupBy(t => t.Tag).Select(g => new { g.Key, Sum = g.Sum(t => t.Amount) }); Assert.AreEqual(261, total.First().Sum); Assert.AreEqual(300, total.Last().Sum); }
public void MoreMoneySpentOnAuto() { var ob = new CheckBookVM(); ob.Fill(); var CheckingAmount = ob.Transactions.Where(p => p.Tag == "Auto" && p.Account == "Checking").Sum(a => a.Amount); var CreditAmount = ob.Transactions.Where(p => p.Tag == "Auto" && p.Account == "Credit").Sum(a => a.Amount); Assert.IsTrue(CheckingAmount == CreditAmount); }
public void PayForEachPayeeForFood() { var ob = new CheckBookVM(); ob.Fill(); var category = "Food"; var totalPay = ob.Transactions.Where(t => t.Tag == category).GroupBy(t => new { t.Payee }).Select((g => new { g.Key, Sum = g.Sum(t => t.Amount) })).ToList(); Assert.AreEqual(130, totalPay[0].Sum); //Assert.AreEqual(0, atotal[1].Sum); Assert.AreEqual(131, totalPay[1].Sum); }