Commit 12f37045 authored by erreiip's avatar erreiip
Browse files

[TEST] Add test

parent 14627e43
Loading
Loading
Loading
Loading
+0 −23
Changes for jeuAssemblage/build.xml: 0 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -61,23 +61,6 @@
			</fileset>
        </jar>
    </target>
    <!--  ==================== Dist Target =====================================  -->
    <target name="test" depends="clean,compile,copy-resources" description="Create binary distribution">
        <copy todir="${dist.home}/lib">
            <fileset dir="${lib.home}"/>
			<fileset dir="${resources.home}"/>
        </copy>
        <!--  Create application JAR file  -->
        <jar jarfile="${dist.home}/${app.fullname}.jar" basedir="${build.home}">
            <manifest>
                <attribute name="Main-Class" value="main.Test"/>
                <attribute name="Class-Path" value="lib/pieces_puzzle-0.1.0.jar lib/flatlaf-2.6.jar"/>
            </manifest>
			<fileset dir="${resources.home}">
				<include name="assets/**"/> <!-- Include all files and subdirectories in the assets folder -->
			</fileset>
        </jar>
    </target>
    <!--  ==================== Javadoc Target ==================================  -->
    <target name="javadoc" depends="compile" description="Create Javadoc API documentation">
        <mkdir dir="${dist.home}/docs/api"/>
@@ -101,12 +84,6 @@
            <java jar="${dist.home}/${app.fullname}.jar" fork="true"/>
        <record name="log.txt" action="stop"/>
    </target>
    <!--  ==================== Run Test Target ==================================  -->
    <target name="run-test" depends="test">
        <record name="log.txt" action="start"/> 
            <java jar="${dist.home}/${app.fullname}.jar" fork="true"/>
        <record name="log.txt" action="stop"/>
    </target>
    <!--  ==================== runWithoutComp Target ==================================  -->
    <target name="run-without-comp">
        <java jar="${dist.home}/${app.fullname}.jar" fork="true"/>
+44 KiB

File added.

No diff preview for this file type.

+376 KiB

File added.

No diff preview for this file type.

+2 −0
Changes for jeuAssemblage/src/model/PlayBoard.java: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -485,6 +485,8 @@ public class PlayBoard extends AbstractListenableHM implements Listener, Compara
		return this.seed;
	}

	// courage à celui qui lira ça, il ne reste plus que 100 lignes

	// -----------------
	// STATIC METHODS
	// -----------------
+57 −0
Changes for jeuAssemblage/src/tests/ModelTest.java: 57 added lines, 0 removed lines.
Original line number Diff line number Diff line
package tests;

import static org.junit.Assert.assertTrue;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import model.PlayBoard;

public class ModelTest {

    public PlayBoard playBoard;

    public int width;
    public int height;
    public Long seed;
    public int nbPiece;

    @Before
    public void setup() {
        this.width = (int) (Math.random() * 13) + 4;
        this.height = (int) (Math.random() * 13) + 4;

        this.seed = (long) (Math.random() * 1000000) + 13;
        this.nbPiece = (int) (Math.random() * 3) + 1;

        this.playBoard = PlayBoard.constructPlayBoard(this.seed, this.width, this.height, this.nbPiece);
    }

    @Test
    public void testPlayboardCreation() {

        assertTrue(this.playBoard.getSeed() == this.seed);
        assertTrue(this.playBoard.getBoardWidth() == this.width);
        assertTrue(this.playBoard.getBoardHeight() == this.height);
        assertTrue(this.playBoard.getPiecesCount() == this.nbPiece);

    }
    
    @Test
    public void testPlayboardCopy() {

        PlayBoard copy = PlayBoard.constructCopyPlayBoard(this.playBoard);

        assertTrue(this.playBoard.equals(copy));
    }
    
    @Test
    public void testPlayboardCreationWithSeed() {

        PlayBoard copy = PlayBoard.constructPlayBoard(this.seed, this.width, this.height, this.nbPiece);

        assertTrue(this.playBoard.equals(copy));
    }

}