Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.