package io.wealthwizards.appsynctesting.utils;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

@DisplayName("$util.math")
public class MathTest {
    @Test
    @DisplayName(".roundNum")
    public void shouldImplementRoundNum() {
        var math = new Math();

        assertEquals(12, math.roundNum(12.3239999d));
        assertEquals(13, math.roundNum(12.99232d));
    }

    @Test
    @DisplayName(".minVal")
    public void shouldImplementMinVal() {
        var math = new Math();

        assertEquals(-12, math.minVal(-12d, 12.3239999d));
    }

    @Test
    @DisplayName(".maxVal")
    public void shouldImplementMaxVal() {
        var math = new Math();

        assertEquals(13, math.maxVal(-12d, 13d));
    }

    @Test
    @DisplayName(".randomDouble")
    public void shouldImplementRandomDouble() {
        var math = new Math();

        // TODO: test properly with Math.random mocked
        assertTrue(math.randomDouble() <= 1);
        assertTrue(math.randomDouble() >= 0);
    }

    @Test
    @DisplayName(".randomWithinRange")
    public void shouldImplementRandomWithinRange() {
        var math = new Math();

        // TODO: test properly with Math.random mocked
        assertTrue(math.randomWithinRange(40, 50) >= 40);
        assertTrue(math.randomWithinRange(40, 50) <= 50);
    }
}
