Monday, December 30, 2013

Happy New Year in TDD way :)

I will wish you only one thing - make those tests pass in one year from now :)
public class NewYearWishesTest {

 private static Year year2014;
 
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
  year2014 = Repository.getYear(2014);
 }
 
 @Test
 public void didYouImprovedYourSkills() {
  SkillsSet skillsIn2013 = Repository.getYear(2013).getSkills();
  SkillsSet skillsIn2014 = year2014.getSkills();
  
  assertFalse(skillsIn2013.equals(skillsIn2014));
  assertTrue(skillsIn2014.size() > skillsIn2013.size());
  
  for (Skill skill : skillsIn2013) {
   Skill skillOneYearLater = skillsIn2014.getByName(skill.getName());
   
   assertTrue(skillOneYearLater.greaterThan(skill));
  }
 }
 
 @Test
 public void didYouAchieveAnotherBigSuccess() {
  ArrayList< Success> successes = year2014.getSuccesses();
  
  assertTrue(successes.size() > 0);
  
  for (Success success : successes) {
   assertTrue(success.isBig());
  }
 }
 
 @Test
 public void doesYourFailuresTeachYouSomething() {
  ArrayList< Failure> failures = year2014.getFailures();
  
  if (failures.size() > 0) {
   for (Failure failure : failures) {
    assertTrue(failure.isEnlightening());
   }
  }
 }
 
 @Test
 public void doYouWorkingAtThePlaceYouWantTo() {
  Work currentWork = year2014.getCurrentWork();
  
  assertTrue(currentWork.getSalary() > getMySalaryExpectations());
  assertTrue(currentWork.getBoss().isCoolPerson());
  
  ArrayList< TeamMember> myTeam = currentWork.getTeam(getNameOfMyTeam());
  
  for (TeamMember teamMember : myTeam) {
   assertEquals(Coolness.ABOVE_THE_LIMITS, teamMember.getLevelOfCoolness());
  }
 }  

 private String getNameOfMyTeam() {}

 private int getMySalaryExpectations() {}
}

I'm leaving for You implementation of the methods getNameOfMyTeam() and getMySalaryExpectations() :)