public ServiceResponse <IList <ExpenseListDTO> > GetAll(long idUser, long idWallet)
        {
            var expenses = _expenseRepository.GetAllExpenses(idUser, idWallet).ToList();

            var expensesDTO = _mapper.Map <IList <ExpenseListDTO> >(expenses);

            return(ServiceResponse <IList <ExpenseListDTO> > .SetSuccess(expensesDTO));
        }
 public void Can_Retrieve_All_Expenses_From_Database()
 {
     using (var repo = new ExpenseRepository(_context))
     {
         _context.Staffs.Add(sampleManager);
         _context.SaveChanges();
         var staff = _context.Staffs.Single();
         repo.Create(new Expense("E1", 2000, staff.Id));
         repo.Create(new Expense("E2", 32000, staff.Id));
         var allExpenses = repo.GetAllExpenses();
         Assert.AreEqual(2, allExpenses.Count);
     }
 }
Exemple #3
0
        public void GetAllExpensesLogsActivity()
        {
            using (var subscription = obsListener.LogToSqlDatabase("Activity", TracingDatabaseConnectionString))
            {
                var repository = new ExpenseRepository(TestDatabaseConnectionString, TimeSpan.MinValue);
                repository.GetAllExpenses();

                subscription.Sink.FlushAsync().Wait();

                var logEntries = DatabaseHelper.GetAllLogEntries(TracingDatabaseConnectionString);

                Assert.AreEqual(3, logEntries.Count());

                var GetAllExpensesStartedEntry = logEntries.SingleOrDefault(e => e.EventId == 300);
                Assert.IsNotNull(GetAllExpensesStartedEntry);

                var GetAllExpensesFinishedEntry = logEntries.SingleOrDefault(e => e.EventId == 301);
                Assert.IsNotNull(GetAllExpensesFinishedEntry);
            }
        }
        public void GetAllExpensesLogsActivity()
        {
            using (var subscription = obsListener.LogToSqlDatabase("Activity", TracingDatabaseConnectionString))
            {
                var repository = new ExpenseRepository(TestDatabaseConnectionString, TimeSpan.MinValue);
                repository.GetAllExpenses();

                subscription.Sink.FlushAsync().Wait();

                var logEntries = DatabaseHelper.GetAllLogEntries(TracingDatabaseConnectionString);

                Assert.AreEqual(3, logEntries.Count());

                var GetAllExpensesStartedEntry = logEntries.SingleOrDefault(e => e.EventId == 300);
                Assert.IsNotNull(GetAllExpensesStartedEntry);

                var GetAllExpensesFinishedEntry = logEntries.SingleOrDefault(e => e.EventId == 301);
                Assert.IsNotNull(GetAllExpensesFinishedEntry);
                
            }
        }
        public void GetAllExpenses()
        {
            var expected = new AExpense.Model.Expense
            {
                Id                  = Guid.NewGuid(),
                Date                = new DateTime(1900, 01, 01),
                Title               = "Title",
                Description         = "Description",
                Total               = 1.0,
                ReimbursementMethod = ReimbursementMethod.DirectDeposit,
                CostCenter          = "CostCenter",
                Approved            = true,
                User                = new User {
                    UserName = "******"
                },
                ApproverName = "approver name"
            };

            var repository = new ExpenseRepository(dataContext);

            repository.SaveExpense(expected);
            var expenses = repository.GetAllExpenses();

            Assert.IsNotNull(expenses);
            var actual = expenses.ToList().Where(e => e.Id == expected.Id).FirstOrDefault();

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Total, actual.Total);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CostCenter, actual.CostCenter);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.ReimbursementMethod, actual.ReimbursementMethod);
            Assert.AreEqual(expected.Title, actual.Title);
            Assert.AreEqual(expected.User.UserName, actual.User.UserName);
        }
        public void GetAllExpenses()
        {
            var expected = new AExpense.Model.Expense
            {
                Id = Guid.NewGuid(),
                Date = new DateTime(1900, 01, 01),
                Title = "Title",
                Description = "Description",
                Total = 1.0,
                ReimbursementMethod = ReimbursementMethod.DirectDeposit,
                CostCenter = "CostCenter",
                Approved = true,
                User = new User { UserName = "******" },
                ApproverName = "approver name"
            };

            var repository = new ExpenseRepository(dataContext);
            repository.SaveExpense(expected);
            var expenses = repository.GetAllExpenses();

            Assert.IsNotNull(expenses);
            var actual = expenses.ToList().Where(e => e.Id == expected.Id).FirstOrDefault();
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Total, actual.Total);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CostCenter, actual.CostCenter);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.ReimbursementMethod, actual.ReimbursementMethod);
            Assert.AreEqual(expected.Title, actual.Title);
            Assert.AreEqual(expected.User.UserName, actual.User.UserName);
        }