class Employee_ {
  // Nom, prénom, etc...

  public reportHours() {}
  public calculatePay() {}
  public save() {}
}

class Employee {
  public constructor(private email: string) {}
  // Nom, prénom, etc...
}

class PayCalculator {
  calculatePay(employee: Employee) {}
}

class HoursReporter {
  reportHours(employee: Employee) {}
}

class EmployeeSaver {
  save(employee: Employee) {}
}

interface EmployeeRepository {
  save(employee: Employee);
}

class PostgresRepository implements EmployeeRepository {
  save(employee: Employee) {
    throw new Error("Method not implemented.");
  }
}

function registerEmployee(repository: EmployeeRepository, email: string) {
  // Validation mot de passe, email, unicité
  const empl = new Employee(email);

  repository.save(empl);
}

// Dans mes tests unitaires

class InMemoryRepository implements EmployeeRepository {
  constructor(public employees: Employee[] = []) {}

  save(employee: Employee) {
    this.employees.push(employee);
  }
}

function TestRegisterUser() {
  const repository = new InMemoryRepository();

  registerEmployee(repository, "un@email.com");

  // assert(repository.employees.length) == 1
}

function TestRegisterUserDuplicateEmail() {
  const repository = new InMemoryRepository([new Employee("un@email.com")]);

  registerEmployee(repository, "un@email.com");

  // assert erreur levée car email dupliqué
}
