hello guys.i've just come into the world of easymock.i'll like to ask if easymock only does mock object for interfaces? So in my effort to understand i wrote a class to generate unique voucher in java.i obviously can't know which value it will generate to use in the assert stuff.So how to make sure the generated voucher is of the type long?
here is the function
public static Long generateID(int length) {
logger.info("Calling generateID with specify length");
Long result = null;
if (length > 0) {
StringBuffer id = new StringBuffer(length);
for (int i = 0; i < length; i++) {
id.append(NUMS[(int)Math.floor(Math.random() * 20)]);
}
result = Long.parseLong(id.toString());
}
return result;
}
here is the test class
@Before
public void setUp() {
mockgenerator = createMock(VGenerator.class);
}
/**
* Test of generateID method, of class VGenerator.
*/
@Test
public void testGenerateID() {
Long exp = (long)1;
int length = 15;
expect(mockgenerator.generateID(length)).equals(Long.class);
replay(mockgenerator);
long res = mockgenerator.generatedID(length);
assertEquals(exp.class, res.class);
}
well this might look terrific to you but i'm still confused about how to do this thanks for helping