public void FindPayeeWithTransactionsWithDateTodayReturnsEmptyTransactionCollection()
        {
            DataHelper.NewDb();

            var service = new RentalsService();

            var actual = service.FindPayeeWithTransactions(1, DateTime.Today, DateTime.Today);

            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Transactions.Count);
        }
        public void FindPayeeWithTransactionsOnSortablePayeeWithDateTodayReturnsTransactionCollection()
        {
            DataHelper.NewDb();
            var payeeId = DataHelper.Payees.Where(a => a.Name == "Sortable Payee").SingleOrDefault().Id;

            var service = new RentalsService();

            var expected = DataHelper.Transactions
                           .Where(t => t.PayeeId == payeeId &&
                                  t.Date == DateTime.Today);
            var actual = service.FindPayeeWithTransactions(payeeId, DateTime.Today, DateTime.Today);

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Count(), actual.Transactions.Count);
        }
        public void CanFindPayeeByIdWithAllItsTransactions()
        {
            DataHelper.NewDb();

            var service = new RentalsService();

            var actual = service.FindPayeeWithTransactions(1);

            var expected = DataHelper.Payees.SingleOrDefault(p => p.Id == 1);

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.DefaultCategoryId, actual.DefaultCategoryId);
            Assert.AreEqual(expected.Memo, actual.Memo);
            Assert.AreEqual(expected.Transactions.Count, actual.Transactions.Count);
        }
        public void FindPayeeWithTransactionsOnSortablePayeeWithDateRangeAndOrderAscendingReturnsSortedTransactionCollection()
        {
            DataHelper.NewDb();
            var payeeId = DataHelper.Payees.Where(a => a.Name == "Sortable Payee").SingleOrDefault().Id;

            var service = new RentalsService();

            var expected = DataHelper.Transactions
                           .Where(t => t.PayeeId == payeeId &&
                                  t.Date >= DateTime.Today.AddMonths(-6) &&
                                  t.Date <= DateTime.Today);
            var actual = service.FindPayeeWithTransactions(payeeId, DateTime.Today.AddMonths(-6), DateTime.Today, true);

            Assert.IsNotNull(actual);
            var order = actual.Transactions.First().Amount;

            foreach (var transaction in actual.Transactions)
            {
                Assert.AreEqual(order, transaction.Amount);
                order += 1.00m;
            }
        }