Skip to content

Instantly share code, notes, and snippets.

View carlosble's full-sized avatar

Carlos Ble carlosble

View GitHub Profile
@carlosble
carlosble / FlightOrders.fs
Created October 4, 2021 14:03
Ejemplo F# de uniones discriminadas y productos
type Percentage = Percentage of float
type ResidentDiscount = ResidentDiscount of Percentage
type FamilyDiscount = FamilyDiscount of Percentage
type SpecialResidentDiscount = SpecialResidentDiscount of Percentage
type BussinesClub = BussinesClub of Percentage
type SpanishSubsidy =
| SpecialResident of SpecialResidentDiscount
| Resident of ResidentDiscount
| Family of FamilyDiscount
//
class Rating {}
class SessionSequence {
private int sequenceNumber;
public SessionSequence(int sequenceNumber){
this.sequenceNumber = sequenceNumber;
}
class ProjectBillingService {
private final CustomerContract contract;
private final DeveloperHistoryRepository repository;
/*...*/
public ProjectBillingService(DeveloperHistoryRepository repository, CustomerContract contract) {
this.repository = repository;
this.contract = contract;
}
/*...*/
public BigDecimal calculateCost(YearMonth yearMonth){
@carlosble
carlosble / BenchmarkTests.java
Created January 19, 2021 08:08
Java benchmark
import org.junit.Test;
import java.util.Arrays;
import java.util.Objects;
import static org.assertj.core.api.Assertions.*;
public class BenchmarkTests {
static class Record implements Comparable<Record> {
import unittest
from camera import Controller, Sensor, Recorder
from doublex import Spy, Stub, assert_that, called
class CameraTestsUsingLibrary(unittest.TestCase):
def test_asks_the_recorder_to_stop_recording_when_no_information_received_from_sensor(self):
sensor = Stub(Sensor)
recorder = Spy(Recorder)
import unittest
from camera import Controller, Sensor, Recorder
class MockMovementSensor(Sensor):
def is_detecting_movement(self) -> bool:
return True
import unittest
from camera import Controller, Sensor, Recorder
class CameraTests(unittest.TestCase):
sensor: Sensor
recorder: Recorder
controller: Controller
import unittest
from camera import Controller, Sensor, Recorder
class CameraTests(unittest.TestCase):
def test_asks_the_recorder_to_stop_recording_when_no_information_received_from_sensor(self):
sensor = Sensor() # mocks
recorder = Recorder() # mocks
self.called = False
class Sensor:
"""Lo vamos a simular"""
def is_detecting_movement(self) -> bool:
pass
class Recorder:
"""Lo vamos a simular"""
def start_recording(self):
@carlosble
carlosble / carts_tests.py
Created July 7, 2020 18:50
cards_tests.py
import unittest
from cards import who_wins
# ToDo List:
# diferente cantidad de cartas -> raise error
# ['1'],['3','4'] -> raise error
# cartas con invalidos,
# 'W' -> raise error