Package com.drighetto.easymock

Examples of com.drighetto.easymock.ExchangeRate


   * @throws java.lang.Exception
   */
  @Test
  public void test01() throws Exception {
    // Define a exchange rate provider with a mock
    ExchangeRate exchangeRateMock = EasyMock.createMock(ExchangeRate.class);
    // Define what is expected to valid the test (configure the mock object
    // created above)
    EasyMock.expect(exchangeRateMock.getRate("USD", "EUR")).andReturn(1.5);
    // Initialize the mock object before to use it
    EasyMock.replay(exchangeRateMock);
    // Define a reference object to valid the test
    Currency cRefObj = new Currency(3.75, "EUR");
    // Define a test object
View Full Code Here


  @Test
  public void test02() throws Exception {
    // Define a exchange rate provider with a mock, we use the
    // "createStrictMock()" method to activate the method call order
    // checking
    ExchangeRate exchangeRateMock = EasyMock.createStrictMock(ExchangeRate.class);
    // Define what is expected to valid the test (configure the mock object
    // created above)
    EasyMock.expect(exchangeRateMock.getRate("USD", "EUR")).andReturn(1.5);
    // Define that the "getRate()" method must call exactly one time !
    EasyMock.expectLastCall().once();
    // Initialize the mock object before to use it
    EasyMock.replay(exchangeRateMock);
    // Define a reference object to valid the test
View Full Code Here

  @Test
  public void test03() throws Exception {
    // Define a exchange rate provider with a mock, we use the
    // "createStrictMock()" method to activate the method call order
    // checking
    ExchangeRate exchangeRateMock = EasyMock.createStrictMock(ExchangeRate.class);
    // Define what is expected to valid the test (configure the mock object
    // created above), we set that method "getRate()" can be call with any
    // not null String parameter value and will always return "1.5" value
    EasyMock.expect(exchangeRateMock.getRate((String) EasyMock.notNull(), (String) EasyMock.notNull())).andReturn(1.5);
    // Define that the "getRate()" method must call exactly one time !
    EasyMock.expectLastCall().once();
    // Initialize the mock object before to use it
    EasyMock.replay(exchangeRateMock);
    // Define a reference object to valid the test
View Full Code Here

   * @throws java.lang.Exception
   */
  @Test
  public void test04() throws IOException {
    // Define a exchange rate provider with a mock
    ExchangeRate exchangeRateMock = EasyMock.createMock(ExchangeRate.class);
    // Define what is expected to valid the test (configure the mock object
    // created above), we set that method "getRate()" can be call with any
    // String parameter value for the second parameter and NULL for the
    // first and will always throw a IOException
    // (and thus the method result will be always NULL)
    EasyMock.expect(exchangeRateMock.getRate((String) EasyMock.isNull(), (String) EasyMock.anyObject())).andThrow(new IOException());
    // Initialize the mock object before to use it
    EasyMock.replay(exchangeRateMock);
    // Define a test object
    Currency cTestObj = new Currency(2.50, null);
    // Run the test using the mock as exchange rate provider
View Full Code Here

TOP

Related Classes of com.drighetto.easymock.ExchangeRate

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.