Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Rhino 3.5 bugs in read/write properties
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
  14 messages - Expand 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
 
TrueWill  
View profile  
 More options Oct 3 2008, 4:56 pm
From: TrueWill <b...@truewill.net>
Date: Fri, 3 Oct 2008 13:56:31 -0700 (PDT)
Local: Fri, Oct 3 2008 4:56 pm
Subject: Rhino 3.5 bugs in read/write properties
I've encountered two bugs in Rhino.Mocks v3.5 for .NET 3.5 when
dealing with interface properties; the combination has proved to be a
showstopper.

Given:

    public interface ISomeThing
    {
        string Name { get; }

        int Number { get; set; }
    }

The following NUnit tests fail:

  [Test]
  public void ReadWritePropertyBug1()
  {
      ISomeThing thing = MockRepository.GenerateStub<ISomeThing>();
      thing.Number = 21;
      thing.Stub(x => x.Name).Return("Bob");
      Assert.That(thing.Number, Is.EqualTo(21));
        // Fails - calling Stub on anything after
        // setting property resets property to default.
  }

  [Test]
  public void ReadWritePropertyBug2()
  {
      ISomeThing thing = MockRepository.GenerateStub<ISomeThing>();
      thing.Stub(x => x.Number).Return(21);
        // InvalidOperationException :
        // Invalid call, the last call has been used...
        // This broke a test on a real project when a
        // { get; } property was changed to { get; set; }.
  }

I realize there are workarounds to both of these bugs (set read/write
properties last, use PropertyBehavior to set read/write properties
instead of Stub), but the first would require significant redesign of
numerous tests in our code base and the second prevents us from simply
not using PropertyBehavior. The second also leads to fragile tests, as
mentioned in the above comment.

If these could be resolved for the release version of 3.5, it would
ease adoption in our company. Thank you!


    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 Oct 3 2008, 5:01 pm
From: "Ayende Rahien" <aye...@ayende.com>
Date: Sat, 4 Oct 2008 00:01:25 +0300
Local: Fri, Oct 3 2008 5:01 pm
Subject: Re: [RhinoMocks] Rhino 3.5 bugs in read/write properties

Are you using the RC version or the trunk?


    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.
Tim Barcz  
View profile  
 More options Oct 3 2008, 8:16 pm
From: "Tim Barcz" <timba...@gmail.com>
Date: Fri, 3 Oct 2008 19:16:58 -0500
Local: Fri, Oct 3 2008 8:16 pm
Subject: Re: [RhinoMocks] Re: Rhino 3.5 bugs in read/write properties

Oren can you confirm if this is a bug or not?  I was bumping into this the
other day and thought that maybe I was doing something wrong....


    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 Oct 3 2008, 8:31 pm
From: "Ayende Rahien" <aye...@ayende.com>
Date: Sat, 4 Oct 2008 03:31:35 +0300
Local: Fri, Oct 3 2008 8:31 pm
Subject: Re: [RhinoMocks] Re: Rhino 3.5 bugs in read/write properties

I would like to know which version this is happening. On the face of it, it
doesn't look like it should do it.


    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.
Tim Barcz  
View profile  
 More options Oct 3 2008, 9:11 pm
From: "Tim Barcz" <timba...@gmail.com>
Date: Fri, 3 Oct 2008 20:11:06 -0500
Local: Fri, Oct 3 2008 9:11 pm
Subject: Re: [RhinoMocks] Re: Rhino 3.5 bugs in read/write properties

I was having similar issues with 3.5.0.2 the other day.  How similar it is
to the scenario below I don't remember the exact scenario.


    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.
TrueWill  
View profile  
 More options Oct 3 2008, 9:22 pm
From: TrueWill <b...@truewill.net>
Date: Fri, 3 Oct 2008 18:22:11 -0700 (PDT)
Local: Fri, Oct 3 2008 9:22 pm
Subject: Re: Rhino 3.5 bugs in read/write properties
The RC.

On Oct 3, 4:01 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.
Tim Barcz  
View profile  
 More options Oct 3 2008, 9:23 pm
From: "Tim Barcz" <timba...@gmail.com>
Date: Fri, 3 Oct 2008 20:23:12 -0500
Local: Fri, Oct 3 2008 9:23 pm
Subject: Re: [RhinoMocks] Re: Rhino 3.5 bugs in read/write properties

Oren,

Can I help by checking or verifying something?


    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 Oct 4 2008, 3:28 am
From: "Ayende Rahien" <aye...@ayende.com>
Date: Sat, 4 Oct 2008 10:28:09 +0300
Local: Sat, Oct 4 2008 3:28 am
Subject: Re: [RhinoMocks] Re: Rhino 3.5 bugs in read/write properties

please try thetrunk and see if it is stil an issue


    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.
TrueWill  
View profile  
 More options Oct 4 2008, 11:43 am
From: TrueWill <b...@truewill.net>
Date: Sat, 4 Oct 2008 08:43:46 -0700 (PDT)
Local: Sat, Oct 4 2008 11:43 am
Subject: Re: Rhino 3.5 bugs in read/write properties
I do not have Subversion, nor am I experienced in its use.

I've provided unit tests that replicate the bugs. If you add them to
your test suite, you'll gain regression testing for these issues as
well.

I realize that you're under no obligation to fix these issues. I'm
simply reporting them and stating that they will prevent wider
adoption of your software.

Thank you

On Oct 4, 2:28 am, "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.
TrueWill  
View profile  
 More options Oct 4 2008, 11:52 am
From: TrueWill <b...@truewill.net>
Date: Sat, 4 Oct 2008 08:52:44 -0700 (PDT)
Local: Sat, Oct 4 2008 11:52 am
Subject: Re: Rhino 3.5 bugs in read/write properties
P.S. If you were replying to Mr. Barcz, I misunderstood, and I
apologize.

On Oct 4, 10:43 am, TrueWill <b...@truewill.net> 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.
Ayende Rahien  
View profile  
 More options Oct 4 2008, 4:10 pm
From: "Ayende Rahien" <aye...@ayende.com>
Date: Sat, 4 Oct 2008 23:10:58 +0300
Local: Sat, Oct 4 2008 4:10 pm
Subject: Re: [RhinoMocks] Rhino 3.5 bugs in read/write properties

The first one is fixed, the second is a problem in the test itself. I added
support for detecting and giving a good error on this scenario:
[TestFixture]
public class FieldProblem_TrueWill
{
    [Test]
    public void ReadWritePropertyBug1()
    {
        ISomeThing thing = MockRepository.GenerateStub<ISomeThing>();
        thing.Number = 21;
        thing.Stub(x => x.Name).Return("Bob");
        Assert.AreEqual(thing.Number, 21);
        // Fails - calling Stub on anything after
        // setting property resets property to default.
    }

    [Test]
    [ExpectedException(typeof(InvalidOperationException), @"You are trying
to set an expectation on a property that was defined to use
PropertyBehavior.
Instead of writing code such as this: mockObject.Stub(x =>
x.SomeProperty).Return(42);
You can use the property directly to achieve the same result:
mockObject.SomeProperty = 42;")]
    public void ReadWritePropertyBug2()
    {
        ISomeThing thing = MockRepository.GenerateStub<ISomeThing>();
        thing.Stub(x => x.Number).Return(21);
        // InvalidOperationException :
        // Invalid call, the last call has been used...
        // This broke a test on a real project when a
        // { get; } property was changed to { get; set; }.
    }


    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.
TrueWill  
View profile  
 More options Oct 4 2008, 5:19 pm
From: TrueWill <b...@truewill.net>
Date: Sat, 4 Oct 2008 14:19:48 -0700 (PDT)
Local: Sat, Oct 4 2008 5:19 pm
Subject: Re: Rhino 3.5 bugs in read/write properties
Thank you very much.

Since PropertyBehavior appears to be on by default for stubs created
by GenerateStub, is there a way to turn it off? I would like to be
able to use the same syntax regardless of whether a property is read-
only or read-write. While it does make the setup more verbose, it
makes the tests less fragile by protecting from interface changes.

In other words, adding a setter to an existing interface breaks
  mockObject.Stub(x => x.SomeProperty).Return(42);
while removing a setter from an existing interface breaks
  mockObject.SomeProperty = 42;

Thanks,
Bill Sorensen

On Oct 4, 3:10 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.
Tim Barcz  
View profile  
 More options Oct 4 2008, 6:25 pm
From: "Tim Barcz" <timba...@gmail.com>
Date: Sat, 4 Oct 2008 17:25:00 -0500
Subject: Re: [RhinoMocks] Rhino 3.5 bugs in read/write properties
As a rhino user I don't know that I would want that feature...

I wouldn't consider a change to a contract (an interface) something a
test should just absorb.

I don't like fragile test but do you thiink that a failing test when
an interface changes is a sign of fagility?

Curious.

Tim

On 10/4/08, TrueWill <b...@truewill.net> wrote:

--
Sent from my mobile device

    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 Oct 4 2008, 10:00 pm
From: "Ayende Rahien" <aye...@ayende.com>
Date: Sun, 5 Oct 2008 05:00:38 +0300
Local: Sat, Oct 4 2008 10:00 pm
Subject: Re: [RhinoMocks] Re: Rhino 3.5 bugs in read/write properties

You can use a mock instead of a stub, and only use Stub().


    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