package com.arles.swissmanager.test.algorithm;

/**
 * Created by Admin on 04.08.2015.
 */
public class MatchTest {
}

@@ -45,74 +45,2734 @@
 m;%0A%0A
-/**%0A * Created by Admin on 04.08.2015.%0A */%0Apublic class MatchTest %7B
+import com.arles.swissmanager.algorithm.Match;%0Aimport com.arles.swissmanager.algorithm.MatchResult;%0Aimport com.arles.swissmanager.algorithm.Points;%0Aimport com.arles.swissmanager.algorithm.Report;%0Aimport com.arles.swissmanager.algorithm.Tournament;%0Aimport com.arles.swissmanager.ui.model.Player;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport static junit.framework.Assert.assertEquals;%0Aimport static junit.framework.Assert.assertTrue;%0A%0A/**%0A * Created by Admin on 04.08.2015.%0A */%0Apublic class MatchTest %7B%0A%0A    private Match mMatch;%0A%0A    @Before%0A    public void setUp() %7B%0A        Player player1 = new Player(%22Player 1%22);%0A        Player player2 = new Player(%22Player 2%22);%0A        mMatch = new Match(player1, player2);%0A    %7D%0A%0A    /**%0A     * Tests method returns report %22invalid%22 when we try to pass invalid match result combination.%0A     */%0A    @Test%0A    public void testReportResult_ReturnInvalid() %7B%0A        Set%3CMatchResult%3E invalidResults = setInvalidResultsCombination();%0A        for(MatchResult result : invalidResults) %7B%0A            Report report = mMatch.reportResult(result.getPlayer1score(), result.getPlayer2score());%0A            assertEquals(%22Report must be Invalid%22, Report.INVALID_RESULT, report);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Tests method returns report %22ok%22 when we try to pass correct match result combination.%0A     */%0A    @Test%0A    public void testReportResult_ReturnOk() %7B%0A        Set%3CMatchResult%3E correctResults = setCorrectResultsCombination();%0A        for(MatchResult result : correctResults) %7B%0A            Report report = mMatch.reportResult(result.getPlayer1score(), result.getPlayer2score());%0A            assertEquals(%22Report must be Ok%22, Report.OK, report);%0A        %7D%0A    %7D%0A%0A%0A    /**%0A     * Set invalid results combination for test.%0A     * For example, players can not both be winners etc.%0A     */%0A    private Set%3CMatchResult%3E setInvalidResultsCombination() %7B%0A        return new HashSet%3CMatchResult%3E() %7B%7B%0A            add(new MatchResult(Points.WIN, Points.WIN));%0A            add(new MatchResult(Points.WIN, Points.DRAW));%0A            add(new MatchResult(Points.DRAW, Points.WIN));%0A        %7D%7D;%0A    %7D%0A%0A    /**%0A     * Set valid results combination for test.%0A     */%0A    private Set%3CMatchResult%3E setCorrectResultsCombination() %7B%0A        return new HashSet%3CMatchResult%3E() %7B%7B%0A            add(new MatchResult(Points.WIN, Points.LOSE));%0A            add(new MatchResult(Points.LOSE, Points.WIN));%0A            add(new MatchResult(Points.DRAW, Points.DRAW));%0A            add(new MatchResult(Points.LOSE, Points.LOSE));%0A            add(new MatchResult(Points.DRAW, Points.LOSE));%0A            add(new MatchResult(Points.LOSE, Points.DRAW));%0A        %7D%7D;%0A    %7D
 %0A%7D%0A

Add test to Match class.