package org.richfaces.model.selection;

import junit.framework.TestCase;

public class SelectionRangeTest extends TestCase {

	SelectionRange range;
	
	public SelectionRangeTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
		range = new SelectionRange(1,3);
	}

	protected void tearDown() throws Exception {
		range = null;
		super.tearDown();
	}

	public void testEqualsHashCode() {
		SelectionRange selectionRange = new SelectionRange(1,3);
		assertTrue(range.equals(selectionRange));
		assertEquals(selectionRange.hashCode(), range.hashCode());
		assertFalse(range.equals(new SelectionRange(1,2)));
	}

	public void testStartIndex() {
		int i = 1;
		range.setStartIndex(i);
		assertEquals(i, range.getStartIndex());
	}

	public void testEndIndex() {
		int i = 1;
		range.setEndIndex(i);
		assertEquals(i, range.getEndIndex());
	}

	public void testWithin() {
		assertTrue(range.within(2));
	}
}
