public void Create_ShouldReturnRedirectToIndex()
        {
            var expenseAccount = new ExpenseAccount();
            var assetAccount = new AssetAccount();

            var model = new CreateModel();
            model.SelectedExpenseAccountId = expenseAccount.Id;
            model.SelectedAssetOrLiabilityAccountId = assetAccount.Id;

            _repository.Stub(x => x.Find<Account>(expenseAccount.Id)).Return(expenseAccount);
            _repository.Stub(x => x.Find<Account>(assetAccount.Id)).Return(assetAccount);

            var controller = GetController();
            var result = (RedirectToRouteResult)controller.Create(model);

            Assert.That(result.RouteValues["action"], Is.EqualTo("Index"));
            Assert.That(result.RouteValues["controller"], Is.EqualTo("Transaction"));
        }
        public void Create_ShouldSaveTransactionToRepository()
        {
            const decimal amount = 100;
            var date = DateTime.Today.AddDays(1);
            const string comments = "something";
            var expenseAccount = new ExpenseAccount();
            var assetAccount = new AssetAccount();

            var model = new CreateModel();
            model.Amount = amount;
            model.Date = date;
            model.Comments = comments;
            model.SelectedExpenseAccountId = expenseAccount.Id;
            model.SelectedAssetOrLiabilityAccountId = assetAccount.Id;

            _repository.Stub(x => x.Find<Account>(expenseAccount.Id)).Return(expenseAccount);
            _repository.Stub(x => x.Find<Account>(assetAccount.Id)).Return(assetAccount);
            _repository.Expect(x => x.Save(Arg<ExpenseTransaction>.Matches(
                y =>
                    (y.Date == date) &&
                    (y.Comments == comments) &&
                    (y.Entries.Count == 2) &&
                    (y.Entries.Any(z => (z.Account.Id == expenseAccount.Id) && (z.Amount == amount) && (z.Type == EntryType.Debit))) &&
                    (y.Entries.Any(z => (z.Account.Id == assetAccount.Id) && (z.Amount == amount) && (z.Type == EntryType.Credit)))))).Return(null);

            var controller = GetController();
            controller.Create(model);

            _repository.VerifyAllExpectations();
        }