I have a question you might help me with.
We need to verify that a method A calls any of the overloaded forms of
method B.
e.g. I have
void B(int)
void B(int, int)
void B(int, int, int)
and I don't care which one of those is called from my method A (at
least one must be called).
Is it possible with Rhino Mocks to define "alternative
expectations" ? Like a set of expectation from which at least one
must be met (or something like .VerifyAnyExpectation instead
of .VerifyAllExpectations) ?
If this is not possible, what would you suggest for this scenario?
What I did now is grouped the 3 methods in the most complex one.
The call B(x) will now be B(x, null, null), but I don't like this work-
around and I'm looking for better alternatives.
The code isn't random as runtime is it? There is logic in place to
determine what actual method should be called. If that is the case you can
assert the different scenarios.
On Mon, Jul 6, 2009 at 8:29 PM, Al <ali.bl...@gmail.com> wrote:
> Hi,
> I have a question you might help me with.
> We need to verify that a method A calls any of the overloaded forms of
> method B.
> e.g. I have
> void B(int)
> void B(int, int)
> void B(int, int, int)
> and I don't care which one of those is called from my method A (at
> least one must be called).
> Is it possible with Rhino Mocks to define "alternative
> expectations" ? Like a set of expectation from which at least one
> must be met (or something like .VerifyAnyExpectation instead
> of .VerifyAllExpectations) ?
> If this is not possible, what would you suggest for this scenario?
> What I did now is grouped the 3 methods in the most complex one.
> The call B(x) will now be B(x, null, null), but I don't like this work-
> around and I'm looking for better alternatives.
I guess this is some sort of state v.s. interactive test. I had the
same need for this.
Yes, there is a logic to determine which is called but this is
implementation detail. If my email service as overloaded sendmail
methods. All I care is one of them is called. Which one is called is
the implementation detail and I don't want my test case to fail if the
implementation changes in future.
There is no direct support from RhinoMocks for this but you can do
below to archive the same result:
}
On Tue, Jul 7, 2009 at 12:52 PM, Tim Barcz<timba...@gmail.com> wrote:
> What is the usage of this....?
> The code isn't random as runtime is it? There is logic in place to
> determine what actual method should be called. If that is the case you can
> assert the different scenarios.
> Tim
> On Mon, Jul 6, 2009 at 8:29 PM, Al <ali.bl...@gmail.com> wrote:
>> Hi,
>> I have a question you might help me with.
>> We need to verify that a method A calls any of the overloaded forms of
>> method B.
>> e.g. I have
>> void B(int)
>> void B(int, int)
>> void B(int, int, int)
>> and I don't care which one of those is called from my method A (at
>> least one must be called).
>> Is it possible with Rhino Mocks to define "alternative
>> expectations" ? Like a set of expectation from which at least one
>> must be met (or something like .VerifyAnyExpectation instead
>> of .VerifyAllExpectations) ?
>> If this is not possible, what would you suggest for this scenario?
>> What I did now is grouped the 3 methods in the most complex one.
>> The call B(x) will now be B(x, null, null), but I don't like this work-
>> around and I'm looking for better alternatives.
> I guess this is some sort of state v.s. interactive test. I had the
> same need for this.
> Yes, there is a logic to determine which is called but this is
> implementation detail. If my email service as overloaded sendmail
> methods. All I care is one of them is called. Which one is called is
> the implementation detail and I don't want my test case to fail if the
> implementation changes in future.
> There is no direct support from RhinoMocks for this but you can do
> below to archive the same result:
> }
> On Tue, Jul 7, 2009 at 12:52 PM, Tim Barcz<timba...@gmail.com> wrote:
> > What is the usage of this....?
> > The code isn't random as runtime is it? There is logic in place to
> > determine what actual method should be called. If that is the case you can
> > assert the different scenarios.
> > Tim
> > On Mon, Jul 6, 2009 at 8:29 PM, Al <ali.bl...@gmail.com> wrote:
> >> Hi,
> >> I have a question you might help me with.
> >> We need to verify that a method A calls any of the overloaded forms of
> >> method B.
> >> e.g. I have
> >> void B(int)
> >> void B(int, int)
> >> void B(int, int, int)
> >> and I don't care which one of those is called from my method A (at
> >> least one must be called).
> >> Is it possible with Rhino Mocks to define "alternative
> >> expectations" ? Like a set of expectation from which at least one
> >> must be met (or something like .VerifyAnyExpectation instead
> >> of .VerifyAllExpectations) ?
> >> If this is not possible, what would you suggest for this scenario?
> >> What I did now is grouped the 3 methods in the most complex one.
> >> The call B(x) will now be B(x, null, null), but I don't like this work-
> >> around and I'm looking for better alternatives.
You are welcome. I understood your pain of writing the test as I have experienced the same. Your request confirmed that I'm not the only one needed this feature so I went ahead and tried something myself.