public
class
ExpectationsConstructorTest2 {
@Test
public
void
testRecordConstrutctor1() {
Calendar cal = Calendar.getInstance();
new
Expectations(Calendar.
class
) {
{
cal.get(Calendar.HOUR_OF_DAY);
result =
7
;
}
};
Calendar now = Calendar.getInstance();
Assert.assertTrue(now.get(Calendar.HOUR_OF_DAY) ==
7
);
Assert.assertTrue(now.get(Calendar.DAY_OF_MONTH) == (
new
Date()).getDate());
}
@Test
public
void
testRecordConstrutctor2() {
Calendar cal = Calendar.getInstance();
new
Expectations(cal) {
{
cal.get(Calendar.HOUR_OF_DAY);
result =
7
;
}
};
Assert.assertTrue(cal.get(Calendar.HOUR_OF_DAY) ==
7
);
Assert.assertTrue(cal.get(Calendar.DAY_OF_MONTH) == (
new
Date()).getDate());
Calendar now = Calendar.getInstance();
Assert.assertTrue(now.get(Calendar.HOUR_OF_DAY) == (
new
Date()).getHours());
Assert.assertTrue(now.get(Calendar.DAY_OF_MONTH) == (
new
Date()).getDate());
}
}