Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Can Rhino do this kind of stub as Moq?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
FrankM  
View profile  
 More options Dec 22 2008, 6:27 pm
From: FrankM <maodd...@gmail.com>
Date: Mon, 22 Dec 2008 15:27:57 -0800 (PST)
Local: Mon, Dec 22 2008 6:27 pm
Subject: Can Rhino do this kind of stub as Moq?
My Moq code:
===================
var mock = new Mock();
// start “tracking” sets/gets to this property
mock.Stub(v => v.Value);
// provide a default value for the stub’ed property
mock.Stub(v => v.Value, 5);

Now I can do:

IHaveValue v = mock.Object;
// Initial value was stored
Assert.Equal(5, v.Value);

// New value set which changes the initial value
v.Value = 6;
Assert.Equal(6, v.Value);
=====================

How can I do the similar stub using Rhino? Thanks.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ayende Rahien  
View profile  
 More options Dec 22 2008, 7:44 pm
From: "Ayende Rahien" <aye...@ayende.com>
Date: Tue, 23 Dec 2008 02:44:58 +0200
Local: Mon, Dec 22 2008 7:44 pm
Subject: Re: [RhinoMocks] Can Rhino do this kind of stub as Moq?

var mock = MockRepository.CreateStub<IFoo>();

mock.Value = 5;

Assert.Equal(5, mock.Value);

mock.Value = 6;

Assert.Equal(6, mock.Value);


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
FrankM  
View profile  
 More options Dec 23 2008, 10:35 am
From: FrankM <maodd...@gmail.com>
Date: Tue, 23 Dec 2008 07:35:54 -0800 (PST)
Local: Tues, Dec 23 2008 10:35 am
Subject: Re: Can Rhino do this kind of stub as Moq?
Thanks. But my MockRepository doesn't have a method called CreateStub,
neither in static nor in instance. My version is 3.5.0.2.

Am I missing something basic?

On Dec 22, 5:44 pm, "Ayende Rahien" <aye...@ayende.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
FrankM  
View profile  
 More options Dec 23 2008, 10:39 am
From: FrankM <maodd...@gmail.com>
Date: Tue, 23 Dec 2008 07:39:29 -0800 (PST)
Local: Tues, Dec 23 2008 10:39 am
Subject: Re: Can Rhino do this kind of stub as Moq?
Sorry, it's GenerateStub(). It works now.

Thanks for your help, very much.

On Dec 22, 5:44 pm, "Ayende Rahien" <aye...@ayende.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
FrankM  
View profile  
 More options Dec 23 2008, 2:57 pm
From: FrankM <maodd...@gmail.com>
Date: Tue, 23 Dec 2008 11:57:24 -0800 (PST)
Local: Tues, Dec 23 2008 2:57 pm
Subject: Re: Can Rhino do this kind of stub as Moq?
Something wrong in mock.Raise() on this kind of stub. It seems this
stub behavior is not available inside the event handler?

My test like this:
           [Test]
            public void should_insert_a_new_item_before_the_current_row
()
            {
                // Arrange , _mockView = MockRepository.GenerateStub()
                _mockView.IndexOfCurrentRow = 1;

                // Action
                _presenter.InitView();

               // This still works
                Assert.That(_mockView.IndexOfCurrentRow, Is.EqualTo
(1));

                _mockView.Raise(x => x.InsertItem += null, this,
EventArgs.Empty);

                // Assert
                Assert.That(_mockView.List.Count, Is.EqualTo
(_stubList.Count + 1));

                // This will fail, the property stub doesn't work in
view.Raise()??
                Assert.That(_mockView.IndexOfCurrentRow, Is.EqualTo
(1));

            }

I have an event in presenter do the insertItem,

        protected virtual void InsertItem(object sender, EventArgs e)
        {
            var list = _view.List;

            int rowIndex = _view.IndexOfCurrentRow; // This will
always be zero, no matter what I set in test. Unless I change
_mockview from GenerateStub to GeneratMock(), but then I can't stub
view.List property anymore.

            var newBO = ...;

            list.Insert(rowIndex, newBO);

            _view.List = list;

            _view.IndexOfCurrentRow = rowIndex;
        }

On Dec 22, 5:44 pm, "Ayende Rahien" <aye...@ayende.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cvetomir Todorov  
View profile  
 More options Dec 26 2008, 3:46 pm
From: "Cvetomir Todorov" <cvetomir.todorov....@gmail.com>
Date: Fri, 26 Dec 2008 22:46:22 +0200
Local: Fri, Dec 26 2008 3:46 pm
Subject: Re: [RhinoMocks] Re: Can Rhino do this kind of stub as Moq?

If you are able to create an isolated test with the issue (meaning it
doesn't contain anything connected with your application) it will be much
easier for others to see what's wrong.

--
Software modules coupling is the path to the dark side.
Coupling leads to complexity.
Complexity leads to confusion.
Confusion leads to suffering.
Once you start down the dark path, forever will it dominate your destiny,
consume you it will!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
FrankM  
View profile  
 More options Jan 1, 7:15 pm
From: FrankM <maodd...@gmail.com>
Date: Thu, 1 Jan 2009 16:15:39 -0800 (PST)
Local: Thurs, Jan 1 2009 7:15 pm
Subject: Re: Can Rhino do this kind of stub as Moq?
OK, here is an isolated one.

var mockvVew = MockRepository.GenerateStub();
mockView.Something = 1;
Assert.Equals(1, mockView.Something);

mockView.Raise(x => x.SomeEvent += null, this, EventArgs.Empty);

//try to read mockView.Something in event handler got zero, instead of
1.

On Dec 26 2008, 1:46 pm, "Cvetomir Todorov"


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google