IAddAddresForm - presumably an interface

On Wed, Aug 19, 2009 at 10:06 PM, Tim Barcz <[email protected]> wrote:

> Is the property virtual?
> Also have you looked at GenerateStub where PropertyBehavior is the default
> behavior?
>
>
> On Wed, Aug 19, 2009 at 1:47 PM, Stephen Schaff <[email protected]> wrote:
>
>>
>> I would really appreciate a working example of using PropertyBehavior
>> in Rhino Mocks 3.5.
>>
>> Here is what I have (that does not work)
>>
>>        [TestMethod]
>>        public void RandomTest()
>>        {
>>            var addressForm =
>> MockRepository.GenerateMock<IAddAddressForm>();
>>
>>            SetupResult.For(addressForm.FirstName).PropertyBehavior();
>>            addressForm.FirstName = "Bob";
>>            string name = addressForm.FirstName;
>>            addressForm.AssertWasCalled(x => { var ignored =
>> x.FirstName; });
>>            Assert.AreEqual(name, addressForm.FirstName);
>>        }
>>
>>
>> This uses the following Interface:
>>        public interface IAddAddressForm
>>        {
>>             string FirstName { get; set; }
>>        }
>>
>> When I run the test I get this error:
>> System.InvalidOperationException: Invalid call, the last call has been
>> used or no call has been made (make sure that you are calling a
>> virtual (C#) / Overridable (VB) method)..
>>
>> If you know what I am doing wrong, then that would be great, but
>> otherwise I would just love a working example of how to make a
>> property of a mock use PropertyBehavior using 3.5 (no Replay/ReplayAll
>> please!  There are Tons of examples using that syntax)
>>
>> Hoping I get a response,
>> Stephen
>>
>>
>>
>>
>
>
> --
> Tim Barcz
> ASPInsider
> http://timbarcz.devlicio.us
> http://www.twitter.com/timbarcz
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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