Ejemplo n.º 1
0
        public ActionResult TransferMoney( TransferMoneyViewModel model )
        {
            TransferService service = new TransferService( _repository );

            string result = service.TransferMoney( model.OriginAccountId, model.DestinationAccountId, model.AmmountToTransfer );

            if ( String.IsNullOrEmpty( result ) )
                ViewBag.Result = "Transferencia exitosa";
            else
                ViewBag.Result = result;

            return View( );

        }
Ejemplo n.º 2
0
        public void TransferMoneyDestinationAccountNotFound( )
        {
            TransferController controller = new TransferController( new FakeAccountRepository( ) );

            TransferMoneyViewModel model = new TransferMoneyViewModel
            {
                OriginAccountId = 1,
                DestinationAccountId = 2000,
                AmmountToTransfer = 100
            };

            ViewResult result = controller.TransferMoney( model ) as ViewResult;

            Assert.AreEqual( "La cuenta de destino no existe", result.ViewBag.Result );
        }
Ejemplo n.º 3
0
        public void TransferMoneyOk( )
        {
            TransferController controller = new TransferController( new FakeAccountRepository( ) );

            TransferMoneyViewModel model = new TransferMoneyViewModel
                                            {
                                                OriginAccountId = 1,
                                                DestinationAccountId = 2,
                                                AmmountToTransfer = 100
                                            };
 
            ViewResult result = controller.TransferMoney( model ) as ViewResult;

            Assert.AreEqual( "Transferencia exitosa", result.ViewBag.Result );
        }
Ejemplo n.º 4
0
        public void TransferMoneyOk2( )
        {
            Mock<IAccountRepository> mockRepository = new Mock<IAccountRepository>( );

            mockRepository.Setup( m => m.Get( 1 ) ).Returns( new Account( ) { Id = 1, Balance = 100 } );
            mockRepository.Setup( m => m.Get( 2 ) ).Returns( new Account( ) { Id = 2, Balance = 500 } );

            TransferController controller = new TransferController( mockRepository.Object );

            TransferMoneyViewModel model = new TransferMoneyViewModel
            {
                OriginAccountId = 1,
                DestinationAccountId = 2,
                AmmountToTransfer = 100
            };

            ViewResult result = controller.TransferMoney( model ) as ViewResult;

            Assert.AreEqual( "Transferencia exitosa", result.ViewBag.Result );
        }
Ejemplo n.º 5
0
        public void TransferMoneyInsufficientsFunds( )
        {
            TransferController controller = new TransferController( new FakeAccountRepository( ) );

            TransferMoneyViewModel model = new TransferMoneyViewModel
            {
                OriginAccountId = 1,
                DestinationAccountId = 2,
                AmmountToTransfer = 10000
            };

            ViewResult result = controller.TransferMoney( model ) as ViewResult;

            Assert.AreEqual( "La cuenta de origen no tiene fondos suficientes", result.ViewBag.Result );
        }