Package com.drighetto.easymock

Examples of com.drighetto.easymock.Currency


    // 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
    Currency cTestObj = new Currency(2.50, "USD");
    // Run the test using the mock as exchange rate provider
    Currency cTestResult = cTestObj.toEuros(exchangeRateMock);
    // Make a assertion to valid the test
    Assert.assertEquals(cRefObj, cTestResult);
  }
View Full Code Here


    // 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
    Currency cRefObj = new Currency(3.75, "EUR");
    // Define a test object
    Currency cTestObj = new Currency(2.50, "USD");
    // Run the test using the mock as exchange rate provider
    Currency cTestResult = cTestObj.toEuros(exchangeRateMock);
    // Make a assertion to valid the test
    Assert.assertEquals(cRefObj, cTestResult);
    // We verify the method call order on the mock
    EasyMock.verify(exchangeRateMock);
  }
View Full Code Here

    // 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
    Currency cRefObj = new Currency(3.75, "EUR");
    // Define a test object
    Currency cTestObj = new Currency(2.50, "USD");
    // Run the test using the mock as exchange rate provider
    Currency cTestResult = cTestObj.toEuros(exchangeRateMock);
    // Make a assertion to valid the test
    Assert.assertEquals(cRefObj, cTestResult);
    // We verify the method call order on the mock
    EasyMock.verify(exchangeRateMock);
  }
View Full Code Here

    // (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
    Currency cTestResult = cTestObj.toEuros(exchangeRateMock);
    // Make a assertion to valid the test
    Assert.assertNull(cTestResult);
    // We verify the method call order on the mock
    EasyMock.verify(exchangeRateMock);
  }
View Full Code Here

TOP

Related Classes of com.drighetto.easymock.Currency

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.