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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
</head> | |
<body> | |
<p>Minute : <span id="minute">0</span></p> | |
<p>Second : <span id="second">0</span></p> | |
<script type="text/javascript"> | |
var second = 0; |
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
interface Authorizer { | |
public Boolean authorize(String username, String password); | |
} |
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 Authorizer interface { | |
Authorize(username, password string) (bool, error) | |
} |
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 DummyAuthorizer implements Authorizer { | |
public Boolean authorize(String username, String password) { | |
return null; | |
} | |
} |
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") | |
} |
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 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 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 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 AcceptingAuthorizerSpy implements Authorizer { | |
public boolean authorizeWasCalled = false; | |
public Boolean authorize(String username, String password) { | |
authorizeWasCalled = true; | |
return true; | |
} | |
} |