public void GivenTheFollowingTransaction(string category, string paymentMethod, Table data) { _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context)); switch (_transactionType) { case TransactionTypes.Income: _transaction = data.CreateInstance<Income>(); _transactionService = new IncomeService(new IncomeRepository(context)); _categoryService = new IncomeCategoryService(new IncomeCategoryRepository(context)); break; case TransactionTypes.Expense: _transaction = data.CreateInstance<Expense>(); _transactionService = new ExpenseService(new ExpenseRepository(context)); _categoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context)); break; } if (!string.IsNullOrWhiteSpace(paymentMethod)) { _paymentMethod = new PaymentMethod(0, paymentMethod); _transaction.Method = _paymentMethod; } if (!string.IsNullOrWhiteSpace(category)) { _category = new DataClasses.Category(0, category); _transaction.Category = _category; } if (_transaction.Date.Equals(default(DateTime))) { _transaction.Date = DateTime.Today; } }
public void GivenTheFollowingTransaction(string category, string paymentMethod, Table data) { _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context)); switch (_transactionType) { case TransactionTypes.Income: _transaction = data.CreateInstance<Income>(); _transactionService = new IncomeService(new IncomeRepository(context)); _categoryService = new IncomeCategoryService(new IncomeCategoryRepository(context)); break; case TransactionTypes.Expense: _transaction = data.CreateInstance<Expense>(); _transactionService = new ExpenseService(new ExpenseRepository(context)); _categoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context)); break; } _paymentMethod = _paymentMethodService.Create(paymentMethod); _transaction.Method = _paymentMethod; _transaction.PaymentMethodId = _paymentMethod.Id; _category = _categoryService.Create(category); _transaction.Category = _category; _transaction.CategoryId = _category.Id; _transaction.Date = DateTime.Today; _transaction.Id = 1; _transactionService.Create(_transaction); }
public void Setup() { context = new TestAccountingDataContext(); _transaction = null; _transactionService = null; _categoryService = null; _paymentMethodService = null; _category = null; _paymentMethod = null; }
public void WhenIPressAdd() { try { if (_category != null) { _category = _categoryService.Create(_category?.Name ?? "not this one"); _transaction.CategoryId = _category.Id; } if (_paymentMethod != null) { _paymentMethod = _paymentMethodService.Create(_paymentMethod?.Name ?? "not this one"); _transaction.PaymentMethodId = _paymentMethod.Id; } _transactionService.Create(_transaction); } catch (Exception e) { ScenarioContext.Current.Add(EXCEPTION_CONTEXT_KEY, e); } }