Created
March 18, 2019 01:59
-
-
Save devjaime/678ad2851fb33371a7b678226335d451 to your computer and use it in GitHub Desktop.
Tomemos ejemplos de dos métodos e intentemos crear pruebas unitarias para ellos.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IAccount | |
| { | |
| double CurrentBallance { get; } | |
| double Deposit(double amount); | |
| double Withdraw(double amount); | |
| } | |
| public class Account : IAccount | |
| { | |
| double _balance; | |
| public double CurrentBallance { get { return _balance; } } | |
| public double Deposit(double amount) | |
| { | |
| if (amount > 0) | |
| { | |
| _balance += amount; | |
| return _balance; | |
| } | |
| else | |
| { | |
| throw new ArgumentException("Invalid Deposit Amount!"); | |
| } | |
| } | |
| public Double Withdraw(double amount) | |
| { | |
| if (amount > 0 && _balance >= amount) | |
| { | |
| _balance -= amount; | |
| } | |
| else | |
| { | |
| throw new ArgumentException("No balance to Withdraw!"); | |
| } | |
| return _balance; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment