Package com.mcorrigal.matchingEngine

Source Code of com.mcorrigal.matchingEngine.AskOrderComparatorTest

package com.mcorrigal.matchingEngine;

import static com.mcorrigal.matchingEngine.TestConstants.dummyLimitSellForPrice;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

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

import com.mcorrigal.matchingEngine.order.SellOrder;
import com.mcorrigal.matchingEngine.orderBook.ask.AskOrderComparator;

public class AskOrderComparatorTest {

  private AskOrderComparator askOrderComparator;
  private SellOrder highPricedOrder = dummyLimitSellForPrice("50");
  private SellOrder lowPricedOrder = dummyLimitSellForPrice("40");
 
  @Before
  public void setUp() {
    askOrderComparator = new AskOrderComparator();
  }
 
  @Test
  public void lowPricedOrderIsHigherPriorityThanHighPricedOrder() {
    assertThat(askOrderComparator.compare(lowPricedOrder, highPricedOrder), is(equalTo(-1)));
  }
 
  @Test
  public void highPricedOrderIsLowerPriorityThanLowPricedOrder() {
    assertThat(askOrderComparator.compare(highPricedOrder, lowPricedOrder), is(equalTo(1)));
  }
 
 
  @Test
  public void twoEqualPricedOrdersHaveSamePricePriority() {
    assertThat(askOrderComparator.compare(highPricedOrder, highPricedOrder), is(equalTo(0)));
  }
 
}
TOP

Related Classes of com.mcorrigal.matchingEngine.AskOrderComparatorTest

TOP
Copyright © 2018 www.massapi.com. 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.