|
EasyMock example source code file (RecordStateInvalidRangeTest.java)
The EasyMock RecordStateInvalidRangeTest.java source code/* * Copyright (c) 2001-2007 OFFIS, Tammo Freese. * This program is made available under the terms of the MIT License. */ package org.easymock.tests; import static org.junit.Assert.*; import org.easymock.MockControl; import org.junit.Before; import org.junit.Test; public class RecordStateInvalidRangeTest { MockControl<IMethods> control; IMethods mock; @Before public void setUp() { control = MockControl.createControl(IMethods.class); mock = control.getMock(); } @Test public void setOpenCallCountTwice() { mock.simpleMethod(); control.setVoidCallable(MockControl.ONE_OR_MORE); try { control.setVoidCallable(MockControl.ONE_OR_MORE); fail(); } catch (IllegalStateException expected) { assertEquals( "last method called on mock already has a non-fixed count set.", expected.getMessage()); } } @Test public void setIllegalMinimumCount() { mock.simpleMethod(); int NEGATIVE = -1; try { control.setVoidCallable(NEGATIVE, 2); fail(); } catch (IllegalArgumentException expected) { assertEquals("minimum must be >= 0", expected.getMessage()); } } @Test public void setIllegalMaximumCount() { mock.simpleMethod(); int NON_POSITIVE = 0; try { control.setVoidCallable(0, NON_POSITIVE); fail(); } catch (IllegalArgumentException expected) { assertEquals("maximum must be >= 1", expected.getMessage()); } } @Test public void setMinimumBiggerThanMaximum() { mock.simpleMethod(); try { control.setVoidCallable(4, 3); fail(); } catch (IllegalArgumentException expected) { assertEquals("minimum must be <= maximum", expected.getMessage()); } } } Other EasyMock examples (source code examples)Here is a short list of links related to this EasyMock RecordStateInvalidRangeTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.