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 class AcceptingAuthorizerFake implements Authorizer { | |
public Boolean authorize(String username, String password) { | |
return username.equals("Bob"); | |
} | |
} |
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
type AcceptingAuthorizerVerificationMock struct { | |
AuthorizeWasCalled bool | |
} | |
func (mock *AcceptingAuthorizerVerificationMock) Authorize(username, password string) (bool, error) { | |
mock.AuthorizeWasCalled = true | |
return true, nil | |
} | |
func (mock *AcceptingAuthorizerVerificationMock) Verify() bool { |
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 class AcceptingAuthorizerVerificationMock implements Authorizer { | |
public boolean authorizeWasCalled = false; | |
public Boolean authorize(String username, String password) { | |
authorizeWasCalled = true; | |
return true; | |
} | |
public boolean verify() { | |
return authorizedWasCalled; |
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
type AcceptingAuthorizerSpy struct { | |
AuthorizeWasCalled bool | |
} | |
func (spy *AcceptingAuthorizerSpy) Authorize(username, password string) (bool, error) { | |
spy.AuthorizeWasCalled = true | |
return true, nil | |
} |
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 class AcceptingAuthorizerSpy implements Authorizer { | |
public boolean authorizeWasCalled = false; | |
public Boolean authorize(String username, String password) { | |
authorizeWasCalled = true; | |
return true; | |
} | |
} |
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
type AcceptingAuthorizerStub struct { | |
} | |
func (stub *AcceptingAuthorizerStub) Authorize(username, password string) (bool, error) { | |
return true, nil | |
} |
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 class AcceptingAuthorizerStub implements Authorizer { | |
public Boolean authorize(String username, String password) { | |
return true; | |
} | |
} |
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
type System struct { | |
Authorizer authorizer.Authorizer | |
} | |
func (system *System) LoginCount() int { | |
return 0 | |
} | |
func TestNewlyCreatedSystemHasNoLoggedInUsers(t *testing.T) { | |
system := &System { &authorizer.DummyAuthorizer{} } |
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 class System { | |
public System(Authorizer authorizer) { | |
this.authorizer = authorizer; | |
} | |
public int loginCount() { | |
//returns number of logged in users. | |
} | |
} |
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
type DummyAuthorizer struct { | |
} | |
func (dummy *DummyAuthorizer) Authorize(username, password string) (bool, error) { | |
return false, errors.New("Don't used Dummy") | |
} |