Created
February 3, 2017 07:01
-
-
Save tarikguney/8af22dfb2f9cef861fa87ac258c56d85 to your computer and use it in GitHub Desktop.
Unit Test Example for Medium
This file contains 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 class AccountCreatorTest{ | |
private IAccountChecker _accountCheckerMock; | |
private IAccountRepository _accountRepositoryMock; | |
[TestInitialize] | |
public void Initialize(){ | |
_accountCheckerMock = new AccountCheckerMock(); | |
_accountRepositoryMock = new AccountRepositoryMock(); | |
} | |
private class AccountCheckerMock: IAccountChecker{ | |
public bool Exists(){ return true; } | |
} | |
private class AccountRepositoryMock: IAccountRepository{ | |
public void Create(){} | |
} | |
[TestMethod] | |
[ExceptedException(typeof(InvalidUsername))] | |
public void TestUsernameIsNotEmpty(){ | |
var accountInfo = new AccountInfo() {UserName="Test"}; | |
var accountCreator = new AccountCreator(_accountChecker, _accountRepository); | |
accountCreator.CreateAccount(accountInfo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment