public void Create_ShouldReturnRedirectToIndex()
        {
            var assetAccount1 = new ExpenseAccount();
            var assetAccount2 = new AssetAccount();

            var model = new CreateModel();
            model.SelectedFromAccountId = assetAccount1.Id;
            model.SelectedToAccountId = assetAccount2.Id;

            _repository.Stub(x => x.Find<Account>(assetAccount1.Id)).Return(assetAccount1);
            _repository.Stub(x => x.Find<Account>(assetAccount2.Id)).Return(assetAccount2);

            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 assetAccount1 = new ExpenseAccount();
            var assetAccount2 = new AssetAccount();

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

            _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.Create(model);

            _repository.VerifyAllExpectations();
        }