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
// inject a function that provides the interface under contract testing | |
function betRepositoryContract(getRepository: () => BetRepository) { | |
test('register a bets', async () => { | |
expect(true).toEqual(false); | |
}) | |
test('bets outside range are not retrieved', async () => { | |
expect(true).toEqual(false); |
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
tenantID, err1 := store.GetParameter("TENANT_ID") | |
clientID, err2 := store.GetParameter("CLIENT_ID") | |
clientSecret, err3 := store.GetParameter("CLIENT_SECRET") | |
globalErr := multierr.Combine(err1, err2, err3) | |
return connection{ | |
tenantID, | |
clientID, | |
clientSecret, | |
}, globalErr |
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
tenantID, err1 := store.GetParameter("TENANT_ID") | |
clientID, err2 := store.GetParameter("CLIENT_ID") | |
clientSecret, err3 := store.GetParameter("CLIENT_SECRET") | |
globalErr := multierr.Combine(err1, err2, err3) | |
if globalErr != nil { | |
fmt.Print(globalErr) | |
return nil, globalErr | |
} |
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
func createConnection(store Store) (Connection, error) { | |
tenantID, err := store.GetParameter("TENANT_ID") | |
if err != nil { | |
fmt.Print("Unable to get TENANT_ID from parameter store") | |
return nil, err | |
} | |
clientID, err := store.GetParameter("CLIENT_ID") | |
if err != nil { | |
fmt.Print("Unable to get CLIENT_ID from parameter store") |
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
// this method is fakable | |
public String getTranslation(String key, Locale locale) { | |
return getTranslationOld(key, locale); | |
} | |
/** | |
* @deprecated use instance method instead | |
*/ | |
public static String getTranslationOld(String key, Locale locale) { | |
Object keys = getTranslationMap().get(locale.toString()); |
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 LazyInitialiserDependency { | |
private static Map<String, Object> translationMap; | |
// no more static initaliser, the class is mockable, though we'll have to go further by | |
// adding a version of getTranslation as an instance method if we want to mock it | |
// this static method is called by the class you'd like to test | |
public static String getTranslation(String key, Locale locale) { |
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 UnTestableDependency { | |
private static Map<String, Object> translationMap; | |
static { | |
translationMap = HibernateUtil.executeQuery("Select ..."); | |
} | |
// this static method is called by the class you'd like to test |
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
private static Map<String, Object> translationMap; | |
static { | |
translationMap = HibernateUtil.executeQuery("Select ..."); | |
} |
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
||| the type Fizzbuzz is just an alias for the tuple of FizzT and BuzzT | |
Fizzbuzz: Nat -> Type | |
Fizzbuzz n = (FizzT n, BuzzT n) |
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
||| proof that k is divisible by 3, can only be called when the compiler can verify it | |
IsFizz : (k : Nat) -> Type | |
IsFizz k = (modNatNZ k 3 SIsNotZ = 0) -- modNatNZ is modulos for natural numbers except for 0. | |
-- SIsNotZ is also a proof about k in this case. Compiler will fail if k is not greater than 0 | |
IsBuzz : Nat -> Type | |
IsBuzz k = (modNatNZ k 5 SIsNotZ = 0) | |
||| There are four constructors : Fizz, Buzz, FizzBuzz, and Normal. |
NewerOlder