Off the top of my head:
ICassInput cassInput = MockRepository.GenerateStub<ICassInput>();
cassInput.Stub(x=> x.BusinessName).Return("XYZ");
On Fri, Oct 31, 2008 at 9:40 AM, Lars Zeb <[EMAIL PROTECTED]> wrote:
>
> I can't get as far as a failing test. The object I want to mock implements
> the ICassInput interface. As you can see, it has only getters, no setters.
> How do I create a mock of this object so that I can get values into a mock
> object based on this interface?
>
> If I write something like:
>
> ICassInput cassInput = MockRepository.GenerateStub<ICassInput>();
> cassInput.BusinessName = "XYZ";
>
> the compiler says:
>
> Property or indexer ICassInput.BusinessName' cannot be assigned to -- it is
> read only
>
> public interface ICassInput
> {
> string FirstName { get; }
> string LastName { get; }
> string MiddleInitial { get; }
> string FullName { get; }
> string BusinessName { get; }
> string AddressLine1 { get; }
> string AddressLine2 { get; }
> string City { get; }
> string State { get; }
> string Zip { get; }
> string SIC { get; }
> string BaseID { get; }
> int AddressID { get; }
> int PersonID { get; }
> long CassDate { get; }
> List<ICassInput> GenerateCassInputAddresses();
> int Result { get; }
> }
> }
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Tim Barcz
> Sent: Thursday, October 30, 2008 3:45 PM
> To: [email protected]
> Subject: [RhinoMocks] Re: Newbie mocking no-setter interface
>
>
> Can you provide the test you are writing that fails?
>
> On 10/30/08, Lars <[EMAIL PROTECTED]> wrote:
> >
> > I am using a third-part dll. It is invoked:
> > Engine<someClass> engine = new Engine<someClass>();
> > where someClass is derived from IInput. Output from this engine is
> > created:
> >
> > IInput[] list = engine.ReadFile("SomePath");
> >
> > IInput has no setters. The engine must populate the IInput-derived
> > class through reflection.
> >
> > How can I mock this class or interface? How do I populate values in
> > the mock?
> >
> > Thanks, Lars
> >
> >
> >
> > >
> >
>
> --
> Sent from my mobile device
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---