Package org.libreplan.business.planner.entities

Examples of org.libreplan.business.planner.entities.Share


                new Share(1))));
    }

    @Test
    public void canKnowTheDifferenceBetweenTwoDivisions() {
        givenDivisionShare(new Share(2), new Share(-5), new Share(-3));
        int[] difference = shareDivision.to(ShareDivision.create(Arrays.asList(
                new Share(1), new Share(1), new Share(-2))));
        assertTrue(Arrays.equals(difference, new int[] { -1, 6, 1 }));
    }
View Full Code Here


        assertTrue(Arrays.equals(difference, new int[] { -1, 6, 1 }));
    }

    @Test
    public void canHandleMaximumValueIntegers() {
        givenDivisionShare(new Share(2), new Share(0), new Share(
                Integer.MAX_VALUE), new Share(Integer.MAX_VALUE), new Share(
                Integer.MAX_VALUE));
        ShareDivision plus = shareDivision.plus(10);
        int[] difference = shareDivision.to(plus);
        assertArrayEquals(new int[] { 4, 6, 0, 0, 0 }, difference);
    }
View Full Code Here

        assertArrayEquals(new int[] { 4, 6, 0, 0, 0 }, difference);
    }

    @Test
    public void canHandleAllMaximumValueIntegers() {
        givenDivisionShare(new Share(Integer.MAX_VALUE), new Share(
                Integer.MAX_VALUE), new Share(Integer.MAX_VALUE));
        ShareDivision plus = shareDivision.plus(2);
        int[] difference = shareDivision.to(plus);
        assertArrayEquals(new int[] { 1, 1, 0 }, difference);
    }
View Full Code Here

        assertArrayEquals(new int[] { 1, 1, 0 }, difference);
    }

    @Test
    public void canHandleMaximumValueIntegersAndMinimumValue() {
        givenDivisionShare(new Share(Integer.MIN_VALUE), new Share(
                Integer.MAX_VALUE), new Share(Integer.MAX_VALUE), new Share(
                Integer.MIN_VALUE), new Share(Integer.MIN_VALUE), new Share(
                Integer.MAX_VALUE));
        ShareDivision plus = shareDivision.plus(9);
        int[] difference = shareDivision.to(plus);
        assertArrayEquals(new int[] { 3, 0, 0, 3, 3, 0 }, difference);
    }
View Full Code Here

    }

    @Test
    @Ignore("TODO handling substractions")
    public void canDistributeSubstraction() {
        givenDivisionShare(new Share(2), new Share(5), new Share(10));
        assertThat(shareDivision.plus(-1), haveValues(2, 5, 9));
    }
View Full Code Here

public class ShareTest {

    private Share share;

    private void givenHours(int hours) {
        share = new Share(hours);
    }
View Full Code Here

        share = new Share(hours);
    }

    @Test
    public void canHaveNegativeHours() {
        new Share(-1);
    }
View Full Code Here

        new Share(-1);
    }

    @Test
    public void canHaveZeroHours() {
        new Share(0);
    }
View Full Code Here

    }

    @Test
    public void canAddHours() {
        givenHours(10);
        Share newShare = share.plus(5);
        assertThat(newShare.getHours(), equalTo(15));
    }
View Full Code Here

    }

    @Test
    public void canSubstract() {
        givenHours(5);
        Share newShare = share.plus(-2);
        assertThat(newShare.getHours(), equalTo(3));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.planner.entities.Share

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.