public void Edit_ShouldSaveTransactionToRepository()
        {
            const decimal amount = 100;
            var date = DateTime.Today.AddDays(1);
            const string comments = "something";
            var incomeAccount = new IncomeAccount();
            var assetAccount = new AssetAccount();
            var IncomeTransaction = new IncomeTransaction();

            var model = new EditModel();
            model.Id = IncomeTransaction.Id;
            model.Amount = amount;
            model.Date = date;
            model.Comments = comments;
            model.SelectedIncomeAccountId = incomeAccount.Id;
            model.SelectedAssetAccountId = assetAccount.Id;

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

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

            _repository.VerifyAllExpectations();
        }
        public void Edit_ShouldReturnRedirectToIndex()
        {
            var IncomeTransaction = new IncomeTransaction();
            var model = new EditModel();
            model.Id = IncomeTransaction.Id;
            model.SelectedIncomeAccountId = Guid.NewGuid();
            model.SelectedAssetAccountId = Guid.NewGuid();

            _repository.Stub(x => x.Find<IncomeTransaction>(IncomeTransaction.Id)).Return(IncomeTransaction);
            _repository.Stub(x => x.Find<Account>(model.SelectedIncomeAccountId)).Return(new IncomeAccount());
            _repository.Stub(x => x.Find<Account>(model.SelectedAssetAccountId)).Return(new AssetAccount());

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

            Assert.That(result.RouteValues["action"], Is.EqualTo("Index"));
            Assert.That(result.RouteValues["controller"], Is.EqualTo("Transaction"));
        }