Understoon, but SerialPort.Open() is not a virtual method. Here is my
code...

[TestMethod]
        public void TestMethod1()
        {
            MockRepository mocks = new MockRepository();
            SerialPort sp = mocks.Stub<SerialPort>();
            using (mocks.Record())
            {
                sp.Open();
                LastCall.Repeat.Any();
            }
            mocks.ReplayAll();
            sp.Open();
            mocks.VerifyAll();
        }

The first 'sp.Open()' inside the Record section is failing.

On Apr 30, 3:27 pm, Shane Courtrille <[email protected]>
wrote:
> Rhino Mocks can mock virtual methods just fine...
>
> On Thu, Apr 30, 2009 at 1:18 PM, wainwrightwt 
> <[email protected]>wrote:
>
>
>
>
>
> > I have been attempting to mock the SerialPort class to no avail.
> > Anytime the .Open() method is called, I get an error stating:
>
> > exception:  System.IO.IOException: The port 'COM1' does not exist..
>
> > It's like the mock object is not being used. I'm assuming it's because
> > SerialPort is not an interface, and the real methods are actually
> > being called. But, Rhino Mocks is supposed to be able to mock classes
> > just fine. I have tried using regular mocks and stubs. Has anyone
> > attempted this, or know what I should try?
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
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