Tnx Tim you did responded

On Mon, May 25, 2009 at 3:56 PM, Tim Barcz <[email protected]> wrote:
> "I need to populate the Columns, Name and FileDataName properties of this
> class"
>
> Ok...you can use RhinoMocks for this, but there is no need.
>
> var stub = new ListFormStruct
>                            {
>                                FileDataName = "MyFile.txt",
>                                Name = "Example",
>                                Columns = new List<ColumnStruct>()
>                            };
>
> 1 - populate the CurrentLine property
> 2 - return true when the NextRecord method will be calls
> 3 - return a dafault value when the GetValue method will be calls
>
> 1. CurrentLine needs to be protected or public in order to set it's value
> 2. You need to mark this method as virtual
> 3. You need to mark this method as virtual
>
> Marking them as virtual will allow RhinoMocks to provide "canned" answers:
>
> var stubReader = MockRepository.GenerateStub<DataReader>();
>
>           stubReader.Stub(x => x.GetValue(0, 8)).Return("test");  // sets up
> a canned answer value for when GetValue(0,8) is called
>
>           var value = stubReader.GetValue(0, 8); // call to GetValue should
> return the previously set up canned answer "test"
>
>           Console.WriteLine(value);
>
> Hope this helps.  If this doesn't help, please post a the test and
> compilable code and we can work from there.
>
> Tim
>
> On Mon, May 25, 2009 at 5:00 AM, Salvatore Di Fazio
> <[email protected]> wrote:
>>
>> I had changed the code that you had read one week ago.
>> Anyway I need to create an instance of one class and:
>>
>> 1 - Populate its property
>> 2 - Get a default value from a method
>>
>> I will show you a bit of these classes:
>>
>>    public class ListFormStruct
>>    {
>>        public string FileDataName { get; set; }
>>        public string Name { get; set; }
>>        public List<ColumnStruct> Columns { get; set; }
>>    }
>>
>> I need to populate the Columns, Name and FileDataName properties of
>> this class, and:
>>
>>    public class DataReader
>>    {
>>        public string GetValue(int startByte, int length)
>>        {
>>            try
>>            {
>>                return CurrentLine.Substring(startByte, length);
>>            }
>>            catch (ArgumentOutOfRangeException aoore)
>>            {
>>                Logger.Write(new LogEntry()
>>                                 {
>>                                     Message = aoore.Message
>>                                 });
>>                return "";
>>            }
>>        }
>>
>>        public bool NextRecord()
>>        {
>>            if (MyStream.EndOfStream)
>>                return false;
>>
>>            CurrentLine = MyStream.ReadLine();
>>
>>            return true;
>>        }
>>
>>        public void SeekToBegin()
>>        {
>>            MyStream.BaseStream.Seek(0, SeekOrigin.Begin);
>>        }
>>
>>        private StreamReader MyStream { get; set; }
>>        private string CurrentLine { get; set; }
>>    }
>>
>> 1 - populate the CurrentLine property
>> 2 - return true when the NextRecord method will be calls
>> 3 - return a dafault value when the GetValue method will be calls
>>
>> Tnx for your help
>>
>>
>> On Mon, May 25, 2009 at 5:17 AM, Tim Barcz <[email protected]> wrote:
>> > I'll be honest here since no one is speaking up....I don't understand
>> > what
>> > you're trying to do.  You've posted some code, which is helpful, but
>> > there's
>> > a lot of code there but I'm going to have to work harder than I'd like
>> > to to
>> > have to understand what it is you're trying to do.
>> >
>> > I've read and re-read the code here and have spent about 15 minutes on
>> > this
>> > email and don't have a clue what advice to give you.  Unfortunately this
>> > is
>> > more time than I typically have to handle.  This leads me to believe
>> > your
>> > code structure has a lot to be desired.  For example it appears your
>> > classes
>> > are doing too much and can be broken apart better.
>> >
>> > I'm sorry to be a wet blanket.  It's not fun for me to not be able to
>> > help
>> > you.
>> >
>> > Tim
>> >
>> > On Sun, May 24, 2009 at 2:33 AM, Salvatore Di Fazio
>> > <[email protected]> wrote:
>> >>
>> >> No one? :-\
>> >>
>> >
>> >
>> > >
>> >
>>
>>
>>
>> --
>> Salvatore Di Fazio
>> http://blogs.ugidotnet.org/SalvoDiFazio/
>>
>>
>
>
> >
>



-- 
Salvatore Di Fazio
http://blogs.ugidotnet.org/SalvoDiFazio/

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