This is not code that I'm the owner of, so unfortunately I can't share
that with you, but this is a simplified version of the
CreateJobQueueForCustomer method.  The jobNumber is actually getting
set as a setting in the config file, but I can't include that or the
name of the file.  I also can't share the code I'm using to populate
the jobParameter list, but I've stepped through the code and the key/
value pair is correctly being populated before the call to
AddNewJobQueueRow. I figured a good way to test the behavior of the
CreateJobQueueForCustomer method wouId be to grab the values of the
key/value pair in the sorted list when the AddNewJobQueueRow is called
and assert the jobNumber is 4 and jobParameter is a SortedList of one
element that contains a key/value pair of "PKEY"/"50".  Does the fact
that I'm creating the jobParameter as a new list in the method rather
than passing it in impact the way Rhino Mocks might handle the stub?

public void CreateJobQueueForCustomer(IJobQueue jobQueue)
{
  try
  {
    int jobNumber = 4;
    var jobParameter = new SortedList();

    // Populate the jobParameter list

    jobQueue.AddNewJobQueueRow(jobNumber, jobParameter);
  }
  catch (Exception ex)
  {
    _errorMessage =
string.Format("MainProcessing.CreateJobQueueForCustomer: Unable to " +
      "create job queue for customer.\n Error Message: {0}", ex);
    throw new Exception(_errorMessage);
  }
}

On Apr 29, 3:55 pm, Patrick Steele <[email protected]> wrote:
> Looking back at your original post, I don't see where
> "jobParameterList" is passed into your MainProcessor.  I guess it
> would probably help if I could see the definition of IJobQueue.
>
> ---
> Patrick Steelehttp://weblogs.asp.net/psteele
>
>
>
>
>
> On Thu, Apr 29, 2010 at 4:23 PM, NateGQG <[email protected]> wrote:
> > Not sure if this is meaningful to our conversation or not, but I took
> > your suggestion and tried it without the .stub call and it still
> > failed however, the following did pass without the .stub call:
>
> > mainProcessing.CreateJobQueueForPatientNotInPm(stubbedJobQueue);
> > stubbedJobQueue.AssertWasCalled(x => x.AddNewJobQueueRow(4, new
> > SortedList()));
>
> > So it recognizes that the AddNewJobQueueRow method was called, it just
> > can't pattern match on the arguments I'm expecting from the call when
> > I use a stub.  More specifically, it can't match on the SortedList
> > argument, it can match on the literal int just fine.  Still unsure as
> > to why, but at least I'm a little further down the rabbit hole than I
> > used to be.
>
> > Thanks
>
> > On Apr 29, 9:09 am, Patrick Steele <[email protected]> wrote:
> >> I do see where there is some confusion.  But from my perspective (the
> >> way I've used RhinoMocks), it doesn't make much sense to Stub a void
> >> method on an interface (unless I have specific processing to do).  If
> >> you just want to make sure a method was called ("AssetWasCalled"), why
> >> stub out its implementation if it's void and doesn't need to return a
> >> canned response?
>
> >> I think your first example would work if you removed the .Stub call.
>
> >> ---
> >> Patrick Steelehttp://weblogs.asp.net/psteele
>
> >> On Thu, Apr 29, 2010 at 9:12 AM, NateGQG <[email protected]> wrote:
> >> > Yes it helps.
>
> >> > And you are correct, we are stubbing the IJobQueue and using depency
> >> > injection so we can test various parts of the main processing class,
> >> > so the AddNewJobQueueRow method is called from
> >> > CreateJobQueueForCustomer method.
>
> >> > However, I still have one question, isn't the method AddNewJobQueueRow
> >> > still getting called whether I stub it or create an expectation for
> >> > it?  To me, whether Rhino Mocks intercepts it and executes my stubbed
> >> > implementation or the actual original implementation is used, the
> >> > method is still getting called.  So from Rhino Mock's perspective,
> >> > providing a stub for a method and then executing that stub is not the
> >> > same as executing the actual method when we're testing for
> >> > AssertWasCalled?
>
> >> > Nate
>
> >> > --
> >> > 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 
> >> > athttp://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 
> >> athttp://groups.google.com/group/rhinomocks?hl=en.-Hide quoted text -
>
> >> - Show quoted text -
>
> > --
> > 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 
> > athttp://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 
> athttp://groups.google.com/group/rhinomocks?hl=en.- Hide quoted text -
>
> - Show quoted text -

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