Skip to content

Instantly share code, notes, and snippets.

data class BuyCryptoInfo(
val username: String,
val phoneNumber: PhoneNumber,
val creditCard: CreditCard,
val kycVerification: KycVerificationData)
fun becomeRich(crypto: CryptoInfo, buyInfo: BuyCryptoInfo) = TODO("conquer the world")
data class CryptoUser(
val username: String,
val name: PersonalName,
val email: Email,
val phoneNumber: PhoneNumber? = null,
val creditCard: CreditCard? = null,
val kycVerification: KycVerificationData? = null)
@lucapiccinelli
lucapiccinelli / barcodestutorial.ipynb
Last active November 29, 2020 07:09
BarcodesTutorial.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
public static void Main(string[] args)
{
// parsing dell'input
int[] inputNumbers = args.Select(int.Parse).ToArray();
// calcolo della totalizzazione
int total = inputNumbers.Sum()
// stampa del totale in output
Console.WriteLine(total);
}
public static void Main(string[] args)
{
Console.WriteLine(args.Select(int.Parse).Sum());
}
@Test
fun `GIVEN springboot in certain state WHEN a restart happens THEN it should preserve the state`(){
val restTemplate = TestRestTemplate()
var webserverPort = Random.nextInt(10000, 10100)
val appContext = SpringApplication.run(MainApplication::class.java, "--server.port=$webserverPort")
restTemplate.getForObject<String>("http://localhost:$webserverPort/hello") shouldBe "Ok 0"
appContext.registerShutdownHook()
class HelloTests {
@Test
fun `GIVEN springboot in certain state WHEN a restart happens THEN it should preserve the state`(){
val restTemplate = TestRestTemplate()
val webserverPort = Random.nextInt(10000, 10100)
val appContext = SpringApplication.run(MainApplication::class.java, "--server.port=$webserverPort")
restTemplate.getForObject<String>("http://localhost:$webserverPort/hello") shouldBe "Ok 0"
@lucapiccinelli
lucapiccinelli / Test1.kt
Created May 26, 2020 06:20
A test that tests the state preservation
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [MainApplication::class])
class HelloTests(@Autowired val restTemplate: TestRestTemplate) {
@Test
fun `GIVEN springboot in certain state WHEN a restart happens THEN it should preserve the state`(){
restTemplate.getForObject<String>("/hello") shouldBe "Ok 0"
restart()
restTemplate.getForObject<String>("/hello") shouldBe "Ok 1"
[FunctionName("HappyDarioBot")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(WebHookType = "genericJson")]HttpRequestMessage req, ILogger log)
{
log.LogInformation("DarioBot was triggered!");
string jsonContent = await req.Content.ReadAsStringAsync();
log.LogInformation(jsonContent);
return req.CreateResponse(HttpStatusCode.OK);
}
interface ArticleConsumer {
fun use(article: ItaArticle)
fun use(article: DeuArticle)
fun use(article: ArticleNotFound)
}
fun useAnArticle(article: Article) : String {
var x = ""
article.applyTo(object : ArticleConsumer {