So it looks like the answer is similar to that of your other question
on the list. That is when you mock something you don't get the
behaviour of the mocked thing.

It doesn't seem necessary to use a mock here. You should generally use
mocks to replace objects that the object your testing depends on so
that you are only testing a single object.

2009/9/11 TJA <[email protected]>:
>
> I forgot to put my setup method
> translation is mocked in that way:
>
> var translation = MockRepository.GenerateMock<Prod.Translation>();
>
> thanks
>
> On 11 sep, 14:59, Alex McMahon <[email protected]> wrote:
>> In your pasted code there doesn't seem to be any mocking going on...
>> That's fine and it sort of looks at first glance like your test should
>> pass....
>>
>> However I'm guessing in your test that translation is a mocked object?
>> in which case depending how you've mocked it this might explain your
>> test failing. For this test is there any reason you need to mock
>> Translation? can't you just create an actual instance of it (or a
>> derived class seeing as it's abstract).
>>
>> 2009/9/11 TJA <[email protected]>:
>>
>>
>>
>>
>>
>> > Hello,
>>
>> > I'm new to Rhino Mocks and I'm trying to mock an event. I found many
>> > blogs where it was explained on MVP model but I didn't find what I
>> > need.
>>
>> > I try ti check if an event was fired after o property was setted.
>>
>> > Heres my class ( part of it):
>>
>> > public delegate void TranslationEventHandler(ITranslation sender,
>> > ChangeBoolValueEventArgs args);
>>
>> > public abstract class Translation : ITranslation
>> > {
>> > public event TranslationEventHandler InitialTranslationChanged;
>>
>> > public Translation()
>> > {
>> >        this.Language = new Language();
>> >        this.IsInitialTranslation = true;
>> >        this.Enabled = true;
>> > }
>>
>> > public virtual bool IsInitialTranslation
>> > {
>> >        get { return isInitialTranslation; }
>> >        set
>> >        {
>> >                if (InitialTranslationChanged != null && 
>> > this.isInitialTranslation !
>> > = value)
>> >                        InitialTranslationChanged(this, new 
>> > ChangeBoolValueEventArgs
>> > (this.isInitialTranslation, value));
>>
>> >                isInitialTranslation = value;
>> >        }
>> > }
>>
>> > Here's my test:
>>
>> > [Test]
>> > public void IsInitialTranslation_SettingProperty_EventIsRised()
>> > {
>> >            bool eventFired = false;
>>
>> >            translation.InitialTranslationChanged += delegate
>> > { eventFired = true; };
>>
>> >            translation.IsInitialTranslation = false;
>>
>> >            Assert.IsTrue(eventFired);
>>
>> > }
>>
>> > The problem is that eventFired is always False.
>>
>> > What I'm doing wrong ?
>>
>> > Thanks for your help.
>>
>> > TJA- Masquer le texte des messages précédents -
>>
>> - Afficher le texte des messages précédents -
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to