nmock2

What are the capabilities of Moq and Rhino.mocks?

I cannot find a specific feature-by-feature comparison of Moq and Rhino. All the questions are "which do you like better and why", or "here's how you do a simple mock in rhino and how it's done in moq". I cannot find a deep comparison anywhere. I'm aware of the syntax differences, I'm not looking for answers about that. I am looking ...

Creating a mock DAO object that returns my Entity class for testing?

I'm looking for a little jump start with mock objects. I have a class called ProjectDAO that has a method called 'GetById' that will load and return a 'Project' object after tripping to the database. GetById takes a single string argument. Public Interface IEntityDAO Function GetByID(ByVal projectNumber As String) As Project End In...

How to check property of function argument in NMock

Hi, Say if i had the following interface mocked in (NMock). How could i check that email.Subject = 'xyz' ? Currently im doing something like IEmailService s = mocks.NewMock<IEmailService>(); Expect.Once.On(s).Method("Send").With(?????) s.Send(new Email { Subject = 'rarr' }); mocks.Verify...(); interface EmailService { void SendEm...

How test SqlParameter for equality

Using NUnit and NMock2 I was not able to compare what I thought were the same SqlParameters: SqlParameter param1 = new SqlParameter("@Id", 1); SqlParameter param2 = new SqlParameter("@Id", 1); Assert.IsTrue(param1.Equals(param2)); // This failed I stumbled across this problem, when trying to test an execution of a method using NMock2...

NMock - how to say expect 'any value' on these params? Or should I not do this?

Hi, I have a quick question that I could not figure out in the docs about NMock2.0. I have a function called Save() that I want to mock out. This takes a string ID as parameter and a decimal as value.. I know I can write this to make sure that Save() gets called with 2 specific values: Expect.Once.On(dao) _ .Method("Save").Wi...

Differences between NMock 2.0 and NMock2

I am a bit confused over which version of NMock2 I should use. The one I've been using for a while I got from here: http://www.nmock.org/download.html The filename is NMock2.dll with version 2.0.0.44. I ran into a problem where I couldn't mock interfaces containing generic functions. After a quick google search found out that NMock2 s...

Help with some mocking

Hi, I was trying to mock an interface and I got the next expection: System.TypeLoadException: System.TypeLoadException: Signature of the body and declaration in a method implementation do not match I figured out later that my problem was a function that I have defined in my interface: IList<T> GetAll<T>() where T : class, new(); ...

Nmock2 and Event Expectations

Im in the process of writing a test for a small application that follows the MVP pattern. Technically, I know I should have written the test before the code, but I needed to knock up a demo app quick smart and so im now going back to the test before moving on to the real development. In short I am attempting to test the presenter, howe...

How to unit test class that reads xml file ?

Hello all I need to write a unit tests for a class that reads a xml file and parses it's content. How can I Mock the file reading ? Because all the content of the tests should be against read file . I use nmock2 with nUnit. Thanks ...

How can I mock an internal interface using NMock2?

If I try this, I just get an exception: System.TypeLoadException : Access is denied: 'Namespace.IInternalInterface'. Making the interface public is not an acceptable solution. I don't want to change the visiblity of my API in order to test it. ...

How to mock Request.Form in NMock2?

Hi Guys, Has anybody mocked Request.Form in NMock2. I found a sample for MOQ but dont know how to translate that in NMock2. var request = Mock.Get(controller.Request) request.Setup(r => r.Form).Returns(delegate() { var nv = new NameValueCollection(); nv.Add("UserName","SomeUser"); nv.Add("Email","[email protected]"); retur...