blob: e98c897f45d5e8ec0e1df8ca1aee1a598bb43c0b [file] [log] [blame]
package groovy.mock.interceptor
import groovy.mock.interceptor.MockFor
import junit.framework.AssertionFailedError
class MockForWithZeroRangeTest extends GroovyTestCase {
void testMockWithZeroRangeDemandAndNoCall() {
MockFor mockForFoo = new MockFor(Foo)
mockForFoo.demand.createBar(0..0) {}
mockForFoo.use {
println 'Foo is not called'
}
// We should get here and the test should pass.
}
void testMockWithZeroRangeDemandAndOneCall() {
MockFor mockForFoo = new MockFor(Foo)
mockForFoo.demand.createBar(0..0) {}
shouldFail(AssertionFailedError) {
mockForFoo.use {
new Foo().createBar()
}
}
}
}
class Foo {
def createBar() {
println 'bar'
}
}