コード例 #1
0
        public IActionResult Expenses()
        {
            List <Expense> txns = new List <Expense>();

            txns = _repo.GetExpenses().ToList();
            var result = txns;

            _logger.LogInformation(200, "Expenses request complete");
            return(Ok(result));
        }
コード例 #2
0
        public void Expenses_OnExecute_ReturnExpenses()
        {
            //Arrange
            ExpensesController controller = new ExpensesController(_repo, _logger);

            //Act
            var            inputDataSource = controller.Expenses();
            var            requestResult   = inputDataSource as OkObjectResult;
            List <Expense> txnList         = (List <Expense>)requestResult.Value;

            //Assert
            Assert.AreEqual(2, txnList.Count);
            CollectionAssert.AreEqual(_repo.GetExpenses().ToList(), txnList, new ExpenseComparer());
        }