Skip to content

Instantly share code, notes, and snippets.

@tarikguney
Created February 3, 2017 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarikguney/8af22dfb2f9cef861fa87ac258c56d85 to your computer and use it in GitHub Desktop.
Save tarikguney/8af22dfb2f9cef861fa87ac258c56d85 to your computer and use it in GitHub Desktop.
Unit Test Example for Medium
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