public void Edit_ShouldSaveTransactionToRepository()
        {
            const decimal amount = 100;
            var date = DateTime.Today.AddDays(1);
            const string comments = "something";
            var assetAccount1 = new AssetAccount();
            var assetAccount2 = new AssetAccount();
            var TransferTransaction = new TransferTransaction();

            var model = new EditModel();
            model.Id = TransferTransaction.Id;
            model.Amount = amount;
            model.Date = date;
            model.Comments = comments;
            model.SelectedFromAccountId = assetAccount1.Id;
            model.SelectedToAccountId = assetAccount2.Id;

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

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

            _repository.VerifyAllExpectations();
        }
        public void Edit_ShouldReturnRedirectToIndex()
        {
            var TransferTransaction = new TransferTransaction();
            var model = new EditModel();
            model.Id = TransferTransaction.Id;
            model.SelectedFromAccountId = Guid.NewGuid();
            model.SelectedToAccountId = Guid.NewGuid();

            _repository.Stub(x => x.Find<TransferTransaction>(TransferTransaction.Id)).Return(TransferTransaction);
            _repository.Stub(x => x.Find<Account>(model.SelectedFromAccountId)).Return(new AssetAccount());
            _repository.Stub(x => x.Find<Account>(model.SelectedToAccountId)).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"));
        }