Off the top of my head I think if you want to stub a read-only property you
need to use the Stub method:

alarmPropertyStub.Stub(x=>x.Value).Return(1);

2010/1/21 Kai <[email protected]>

> Hello.
>
> I have just started using Rhino mocks and have a little question. Many
> of our interfaces have properties, but the set method is omitted. The
> properties are set in the class that implements the interface. Is
> there a way to use Rhino Mocks to stub interface like that?
>
> I keep gettign this compilation error.
> error CS0200: Property or indexer IManagedAlarmProperty.DataType'
> cannot be assigned to -- it is read only
>
> Here is my interface:
>  public interface IManagedAlarmProperty
>    {
>        /// <summary>
>        /// Property value
>        /// </summary>
>        object Value { get; }
>
>        /// <summary>
>        /// datatype of property
>        /// </summary>
>        Type DataType { get; }
>    }
>
> Here is my method that stubs this interface.
>        static IManagedOskAlarmProperty CreateAlarmProperty(string
> property)
>        {
>            IManagedOskAlarmProperty alarmPropertyStub =
> MockRepository.GenerateStub<IManagedOskAlarmProperty>();
>            alarmPropertyStub.DataType = typeof(double);       <---
> compilation error.
>            alarmPropertyStub.Value = 1;
> <-- compilation error.
> return alarmPropertyStub;
>        }
>
>
>
> Thanks,
> Kai
>
> --
> 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]<rhinomocks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhinomocks?hl=en.
>
>
>
>
--
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