Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expectation counts wrong the method calls #70

Open
inner-peace opened this issue May 28, 2015 · 0 comments
Open

Expectation counts wrong the method calls #70

inner-peace opened this issue May 28, 2015 · 0 comments

Comments

@inner-peace
Copy link

Hi Drew

I try to use expect() instead received() and find the problem (received() works properly). Clean test below

package {
import flash.events.Event;
import flash.events.EventDispatcher;

import mockolate.arg;
import mockolate.expect;
import mockolate.runner.MockolateRule;

import org.hamcrest.core.anything;
import org.hamcrest.object.hasProperty;

public class FoobarTest {

    [Rule]
    public var rule:MockolateRule = new MockolateRule();

    [Mock]
    public var ed:EventDispatcher;

    [Test]
    public function works():void {
        expect(ed.dispatchEvent(arg(anything()))).twice();
        expect(ed.dispatchEvent(arg(hasProperty('type', '1'))));
        expect(ed.dispatchEvent(arg(hasProperty('type', '2'))));

        ed.dispatchEvent(new Event('1'));
        ed.dispatchEvent(new Event('2'))
    }

    [Test]
    public function notWorks():void {
        expect(ed.dispatchEvent(arg(anything()))).thrice();
        expect(ed.dispatchEvent(arg(hasProperty('type', '1')))).twice();
        expect(ed.dispatchEvent(arg(hasProperty('type', '2'))));

        ed.dispatchEvent(new Event('1'));
        ed.dispatchEvent(new Event('1'));
        ed.dispatchEvent(new Event('2'))
    }

    [Test]
    public function butAgainWorks():void {
        expect(ed.dispatchEvent(arg(hasProperty('type', '1')))).twice();
        expect(ed.dispatchEvent(arg(hasProperty('type', '2'))));

        ed.dispatchEvent(new Event('1'));
        ed.dispatchEvent(new Event('1'));
        ed.dispatchEvent(new Event('2'))
    }

}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant