Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#17 Expectation Ordering doesn't catch missed expectations

closed-fixed
Mike Capp
None
5
2007-05-29
2006-11-29
No

If you have an ordering of expectations you do not get an ExpectedException when you only satisfy the first\ expectation.

Try the following test:
using NUnit.Framework;

namespace NMock2.AcceptanceTests
{
public interface IHelloWorld
{
void Hello();
void Umm();
void Err();
void Ahh();
void Goodbye();
string Ask(string question);
}

[TestFixture]
public class MissingOrderedCallsTest
{
private Mockery mocks;
private IHelloWorld helloWorld;

[SetUp]
public void SetUp()
{
mocks = new Mockery();
helloWorld = (IHelloWorld)mocks.NewMock(typeof(IHelloWorld));
}

[Test, ExpectedException(typeof(ExpectationException))]
public void MissingCallsWithinAnInOrderedBlockThrowsExpectationException()
{
using (mocks.Ordered)
{
Expect.Once.On(helloWorld).Method("Hello");
Expect.Once.On(helloWorld).Method("Goodbye");
}
helloWorld.Hello();
}
}
}

This test should pass.

Discussion

  • Patch with a test and a bugfix.

     
    Attachments
  • Mike Capp
    Mike Capp
    2007-05-29

    Logged In: YES
    user_id=1108609
    Originator: NO

    Fixed in CVS. Note though that your test won't throw an ExpectationException until you call mocks.VerifyAllExpectationsHaveBeenMet().

     
  • Mike Capp
    Mike Capp
    2007-05-29

    • assigned_to: nobody --> mcapp
    • status: open --> closed-fixed