

package com.dmdirc.util.validators;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@RunWith(MockitoJUnitRunner.class)
public class IntegerPortValidatorTest {

    @Test
    public void testValidate_TooLow() throws Exception {
        assertTrue(new IntegerPortValidator().validate(0).isFailure());
    }

    @Test
    public void testValidate_Min() throws Exception {
        assertFalse(new IntegerPortValidator().validate(1).isFailure());
    }

    @Test
    public void testValidate_Normal() throws Exception {
        assertFalse(new IntegerPortValidator().validate(5).isFailure());
    }

    @Test
    public void testValidate_Max() throws Exception {
        assertFalse(new IntegerPortValidator().validate(65535).isFailure());
    }

    @Test
    public void testValidate_TooHigh() throws Exception {
        assertTrue(new IntegerPortValidator().validate(65536).isFailure());
    }

}